Skip to content

Commit e22b6e2

Browse files
authored
[Fix] 날씨 요청 타임존 설정 및 로그 추가 (#246)
fix: 날씨 요청 타임존 설정 및 로그 추가
1 parent 66960ab commit e22b6e2

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/main/java/org/programmers/signalbuddyfinal/domain/weather/service/WeatherProvider.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import com.fasterxml.jackson.databind.ObjectMapper;
66
import java.time.LocalDate;
77
import java.time.LocalTime;
8+
import java.time.ZoneId;
9+
import java.time.ZonedDateTime;
810
import java.time.format.DateTimeFormatter;
911
import java.util.List;
1012
import lombok.RequiredArgsConstructor;
@@ -34,11 +36,18 @@ public class WeatherProvider {
3436
private String apiKey;
3537

3638
public List<Weather> requestWeatherApi(int nx, int ny) {
37-
final String currentDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
39+
final String localDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
40+
final String localTime = LocalTime.now().minusMinutes(6)
41+
.format(DateTimeFormatter.ofPattern("HHmm"));
42+
43+
log.info("Local Date: {}, Local Time: {}", localDate, localTime);
44+
final String currentDate = ZonedDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
3845
// 정시에 맞춰서 요청하면 아직 데이터가 존재하지 않아서 6분전 데이터 요청
3946
// 15:05 인데 15:00 데이터 존재하지 않음.
40-
final String currentTime = LocalTime.now().minusMinutes(6)
47+
final String currentTime = ZonedDateTime.now(ZoneId.of("Asia/Seoul")).minusMinutes(6)
4148
.format(DateTimeFormatter.ofPattern("HHmm"));
49+
log.info("Zoned Date: {}, Zoned Time: {}", currentDate, currentTime);
50+
4251
final String responseJson = webClient.get().uri(ultraSrtNcst,
4352
uriBuilder -> uriBuilder.queryParam("serviceKey", apiKey).queryParam("pageNo", 1)
4453
.queryParam("numOfRows", 1000).queryParam("dataType", "JSON")

src/main/java/org/programmers/signalbuddyfinal/domain/weather/service/WeatherService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ public void sendWeatherUpdates() {
149149
}
150150

151151
private void sendWeatherUpdate(SseEmitter emitter, double nx, double ny) {
152+
log.info("날씨 데이터 요청: 좌표({},{})", nx, ny);
152153
final WeatherResponse weatherData = getWeatherData(nx, ny);
153154
try {
154155
emitter.send(SseEmitter.event().name(WEATHER_EVENT_NAME).data(weatherData));

0 commit comments

Comments
 (0)