-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
135 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...her-service/src/main/java/com/waither/weatherservice/dto/request/GetWindChillRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.waither.weatherservice.dto.request; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import jakarta.validation.constraints.DecimalMax; | ||
import jakarta.validation.constraints.DecimalMin; | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
public record GetWindChillRequest( | ||
@NotNull(message = "[ERROR] 위도 입력은 필수 입니다.") | ||
@DecimalMin(value = "33.0", message = "[ERROR] 위도는 33.0도에서 43.0도 사이여야 합니다.") | ||
@DecimalMax(value = "43.0", message = "[ERROR] 위도는 33.0도에서 43.0도 사이여야 합니다.") | ||
Double latitude, | ||
@NotNull(message = "[ERROR] 경도 입력은 필수 입니다.") | ||
@DecimalMin(value = "124.0", message = "[ERROR] 경도는 124.0도에서 132.0도 사이여야 합니다.") | ||
@DecimalMax(value = "132.0", message = "[ERROR] 경도는 124.0도에서 132.0도 사이여야 합니다.") | ||
Double longitude, | ||
@NotNull(message = "[ERROR] 날짜 입력은 필수 입니다.") | ||
LocalDateTime baseTime | ||
) | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
weather-service/src/main/java/com/waither/weatherservice/utills/DateTimeUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.waither.weatherservice.utills; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class DateTimeUtils { | ||
|
||
public static LocalDateTime convertLocalDateTimeToDailyWeatherTime(LocalDateTime time) { | ||
|
||
// DailyWeather 정보는 3시간마다 | ||
List<Integer> scheduledHours = Arrays.asList(0, 3, 6, 9, 12, 15, 18, 21); | ||
|
||
int currentHour = time.getHour(); | ||
int adjustedHour = scheduledHours.stream() | ||
.filter(hour -> hour <= currentHour) | ||
.reduce((first, second) -> second) | ||
.orElse(scheduledHours.get(scheduledHours.size() - 1)); // 이전 날의 마지막 스케줄 시간(21시) 반환 | ||
|
||
// 현재 시간이 첫 스케줄 시간(0시)보다 작을 경우, 전날의 마지막 스케줄 시간으로 설정 | ||
if (currentHour < scheduledHours.get(0)) { | ||
time = time.minusDays(1); | ||
} | ||
|
||
return time.withHour(adjustedHour).withMinute(0).withSecond(0).withNano(0); | ||
} | ||
|
||
public static String convertLocalDateTimeToString(LocalDateTime time) { | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); | ||
String formattedDateTime = time.format(formatter); | ||
|
||
String[] lst = formattedDateTime.split(" "); | ||
String baseDate = lst[0].replace("-", ""); | ||
|
||
String[] temp = lst[1].split(":"); | ||
String baseTime = temp[0] + "00"; | ||
|
||
return baseDate + "_" + baseTime; | ||
} | ||
|
||
public static String convertLocalDateToString(LocalDate localDate) { | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); | ||
return localDate.format(formatter); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../waither/weatherservice/gps/LatXLngY.java → ...ither/weatherservice/utills/LatXLngY.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.waither.weatherservice.gps; | ||
package com.waither.weatherservice.utills; | ||
|
||
import lombok.Builder; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters