Skip to content

Commit 83c2501

Browse files
committed
[fix] 기상청 API 강설량 예상하지 못한 응답 대응
1 parent aa3aa7b commit 83c2501

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main/java/nambang_swag/bada_on/entity/Weather.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ public void updateWeatherData(String category, String value) {
123123
case "PCP", "RN1" -> hourlyPrecipitation = parseAccumulation(value, "강수없음");
124124
case "REH" -> humidity = parseInt(value);
125125
case "SNO" -> hourlySnowAccumulation = parseAccumulation(value, "적설없음");
126+
126127
}
127128
} catch (NumberFormatException e) {
128129
throw new IllegalArgumentException("Failed to parse value: " + value + " for category: " + category, e);
@@ -141,6 +142,12 @@ private float parseAccumulation(String value, String noneString) {
141142
if (value.equals(noneString)) {
142143
return NO_DATA;
143144
}
145+
146+
if (value.endsWith("cm미만")) {
147+
String numericPart = value.substring(0, value.indexOf("cm"));
148+
return Float.parseFloat(numericPart) / 10; // Convert cm to mm
149+
}
150+
144151
return parseFloat(value.split("mm")[0]);
145152
}
146153
}

0 commit comments

Comments
 (0)