From cf88fddfdbaf5d75d6ded30dd248cbfce202342c Mon Sep 17 00:00:00 2001 From: Khoroshkova Alexandra Date: Thu, 19 Dec 2024 22:41:32 +0300 Subject: [PATCH] fix data --- .../moevm/nosql2h24/dogs/controller/StatisticController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cats/src/main/java/com/github/moevm/nosql2h24/dogs/controller/StatisticController.java b/cats/src/main/java/com/github/moevm/nosql2h24/dogs/controller/StatisticController.java index c0c0b39..0abeeba 100644 --- a/cats/src/main/java/com/github/moevm/nosql2h24/dogs/controller/StatisticController.java +++ b/cats/src/main/java/com/github/moevm/nosql2h24/dogs/controller/StatisticController.java @@ -17,6 +17,7 @@ import org.springframework.web.server.ResponseStatusException; import java.time.LocalDateTime; +import java.time.ZoneId; import java.time.ZoneOffset; import java.util.*; import java.util.stream.Collectors; @@ -45,8 +46,8 @@ public Data getStatistic( @RequestParam(value = "ageTo", required = false) Integer ageTo, @RequestParam(value = "limit", required = false) Integer limit, @RequestParam(value = "breeds", required = false) List breeds) { - Date localDateFrom = dateFrom == null ? null : Date.from(LocalDateTime.parse(dateFrom).toInstant(ZoneOffset.UTC)); - Date localDateTo = dateTo == null ? null : Date.from(LocalDateTime.parse(dateTo).toInstant(ZoneOffset.UTC)); + Date localDateFrom = dateFrom == null ? null : Date.from(LocalDateTime.parse(dateFrom).atZone(ZoneId.systemDefault()).toInstant()); + Date localDateTo = dateTo == null ? null : Date.from(LocalDateTime.parse(dateTo).atZone(ZoneId.systemDefault()).toInstant()); StatisticType statisticType; try { statisticType = StatisticType.valueOf(type.toUpperCase());