From 3bb0eb043de012184672974036ead6a7480943ae Mon Sep 17 00:00:00 2001 From: Prominence Date: Thu, 5 Jul 2018 23:32:39 +0300 Subject: [PATCH] Fixed issue with datetime storing and printing. --- .../openweather/api/model/WeatherResponse.java | 10 +++++----- .../api/model/WeatherSystemInfo.java | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/java/by/prominence/openweather/api/model/WeatherResponse.java b/src/main/java/by/prominence/openweather/api/model/WeatherResponse.java index ca47240..e2d9979 100644 --- a/src/main/java/by/prominence/openweather/api/model/WeatherResponse.java +++ b/src/main/java/by/prominence/openweather/api/model/WeatherResponse.java @@ -24,7 +24,7 @@ package by.prominence.openweather.api.model; import com.alibaba.fastjson.annotation.JSONField; -import java.time.LocalTime; +import java.util.Date; import java.util.List; public class WeatherResponse { @@ -60,7 +60,7 @@ public class WeatherResponse { private Snow snow; @JSONField(name = "dt") - private LocalTime dataCalculationTime; + private long dataCalculationTime; @JSONField(name = "sys") private WeatherSystemInfo weatherSystemInfo; @@ -148,11 +148,11 @@ public class WeatherResponse { this.snow = snow; } - public LocalTime getDataCalculationTime() { + public long getDataCalculationTime() { return dataCalculationTime; } - public void setDataCalculationTime(LocalTime dataCalculationTime) { + public void setDataCalculationTime(long dataCalculationTime) { this.dataCalculationTime = dataCalculationTime; } @@ -185,7 +185,7 @@ public class WeatherResponse { ",\n clouds=" + clouds + ",\n rain=" + rain + ",\n snow=" + snow + - ",\n dataCalculationTime=" + dataCalculationTime + + ",\n dataCalculationTime=" + new Date(dataCalculationTime * 1000) + ",\n weatherSystemInfo=" + weatherSystemInfo + ",\n responseCode=" + responseCode + '}'; diff --git a/src/main/java/by/prominence/openweather/api/model/WeatherSystemInfo.java b/src/main/java/by/prominence/openweather/api/model/WeatherSystemInfo.java index 6efd776..883fa6a 100644 --- a/src/main/java/by/prominence/openweather/api/model/WeatherSystemInfo.java +++ b/src/main/java/by/prominence/openweather/api/model/WeatherSystemInfo.java @@ -24,7 +24,7 @@ package by.prominence.openweather.api.model; import com.alibaba.fastjson.annotation.JSONField; -import java.time.LocalTime; +import java.util.Date; import java.util.Objects; public class WeatherSystemInfo { @@ -47,11 +47,11 @@ public class WeatherSystemInfo { @JSONField(name = "sunrise") // Sunrise time, unix, UTC - private LocalTime sunrise; + private long sunrise; @JSONField(name = "sunset") // Sunset time, unix, UTC - private LocalTime sunset; + private long sunset; public short getType() { return type; @@ -85,19 +85,19 @@ public class WeatherSystemInfo { this.country = country; } - public LocalTime getSunrise() { + public long getSunrise() { return sunrise; } - public void setSunrise(LocalTime sunrise) { + public void setSunrise(long sunrise) { this.sunrise = sunrise; } - public LocalTime getSunset() { + public long getSunset() { return sunset; } - public void setSunset(LocalTime sunset) { + public void setSunset(long sunset) { this.sunset = sunset; } @@ -108,8 +108,8 @@ public class WeatherSystemInfo { ", id=" + id + ", message=" + message + ", country='" + country + '\'' + - ", sunrise=" + sunrise + - ", sunset=" + sunset + + ", sunrise=" + new Date(sunrise * 1000) + + ", sunset=" + new Date(sunset * 1000) + '}'; }