Fixed issue with datetime storing and printing.

This commit is contained in:
Prominence 2018-07-05 23:32:39 +03:00
parent 37d9a1cf5b
commit 3bb0eb043d
2 changed files with 14 additions and 14 deletions

View File

@ -24,7 +24,7 @@ package by.prominence.openweather.api.model;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import java.time.LocalTime; import java.util.Date;
import java.util.List; import java.util.List;
public class WeatherResponse { public class WeatherResponse {
@ -60,7 +60,7 @@ public class WeatherResponse {
private Snow snow; private Snow snow;
@JSONField(name = "dt") @JSONField(name = "dt")
private LocalTime dataCalculationTime; private long dataCalculationTime;
@JSONField(name = "sys") @JSONField(name = "sys")
private WeatherSystemInfo weatherSystemInfo; private WeatherSystemInfo weatherSystemInfo;
@ -148,11 +148,11 @@ public class WeatherResponse {
this.snow = snow; this.snow = snow;
} }
public LocalTime getDataCalculationTime() { public long getDataCalculationTime() {
return dataCalculationTime; return dataCalculationTime;
} }
public void setDataCalculationTime(LocalTime dataCalculationTime) { public void setDataCalculationTime(long dataCalculationTime) {
this.dataCalculationTime = dataCalculationTime; this.dataCalculationTime = dataCalculationTime;
} }
@ -185,7 +185,7 @@ public class WeatherResponse {
",\n clouds=" + clouds + ",\n clouds=" + clouds +
",\n rain=" + rain + ",\n rain=" + rain +
",\n snow=" + snow + ",\n snow=" + snow +
",\n dataCalculationTime=" + dataCalculationTime + ",\n dataCalculationTime=" + new Date(dataCalculationTime * 1000) +
",\n weatherSystemInfo=" + weatherSystemInfo + ",\n weatherSystemInfo=" + weatherSystemInfo +
",\n responseCode=" + responseCode + ",\n responseCode=" + responseCode +
'}'; '}';

View File

@ -24,7 +24,7 @@ package by.prominence.openweather.api.model;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
import java.time.LocalTime; import java.util.Date;
import java.util.Objects; import java.util.Objects;
public class WeatherSystemInfo { public class WeatherSystemInfo {
@ -47,11 +47,11 @@ public class WeatherSystemInfo {
@JSONField(name = "sunrise") @JSONField(name = "sunrise")
// Sunrise time, unix, UTC // Sunrise time, unix, UTC
private LocalTime sunrise; private long sunrise;
@JSONField(name = "sunset") @JSONField(name = "sunset")
// Sunset time, unix, UTC // Sunset time, unix, UTC
private LocalTime sunset; private long sunset;
public short getType() { public short getType() {
return type; return type;
@ -85,19 +85,19 @@ public class WeatherSystemInfo {
this.country = country; this.country = country;
} }
public LocalTime getSunrise() { public long getSunrise() {
return sunrise; return sunrise;
} }
public void setSunrise(LocalTime sunrise) { public void setSunrise(long sunrise) {
this.sunrise = sunrise; this.sunrise = sunrise;
} }
public LocalTime getSunset() { public long getSunset() {
return sunset; return sunset;
} }
public void setSunset(LocalTime sunset) { public void setSunset(long sunset) {
this.sunset = sunset; this.sunset = sunset;
} }
@ -108,8 +108,8 @@ public class WeatherSystemInfo {
", id=" + id + ", id=" + id +
", message=" + message + ", message=" + message +
", country='" + country + '\'' + ", country='" + country + '\'' +
", sunrise=" + sunrise + ", sunrise=" + new Date(sunrise * 1000) +
", sunset=" + sunset + ", sunset=" + new Date(sunset * 1000) +
'}'; '}';
} }