Merge pull request 'fix: toLocalDateTime 변환 강화' (#22) from feature/dashboard-phase-1 into develop

This commit is contained in:
htlee 2026-02-19 18:39:50 +09:00
커밋 b46b9335a0

파일 보기

@ -228,14 +228,23 @@ public class MonitoringController {
return quality;
}
private static LocalDateTime toLocalDateTime(Object raw) {
if (raw instanceof java.sql.Timestamp ts) {
return ts.toLocalDateTime();
} else if (raw instanceof java.time.OffsetDateTime odt) {
return odt.toLocalDateTime();
} else if (raw instanceof LocalDateTime ldt) {
return ldt;
private LocalDateTime toLocalDateTime(Object raw) {
if (raw == null) return null;
if (raw instanceof LocalDateTime ldt) return ldt;
if (raw instanceof java.sql.Timestamp ts) return ts.toLocalDateTime();
if (raw instanceof java.time.OffsetDateTime odt) return odt.toLocalDateTime();
if (raw instanceof java.time.Instant inst) {
return inst.atZone(java.time.ZoneId.systemDefault()).toLocalDateTime();
}
log.warn("Unexpected temporal type: {} (class={})", raw, raw.getClass().getName());
try {
String s = raw.toString();
if (s.contains("+") || s.endsWith("Z")) {
return java.time.OffsetDateTime.parse(s).toLocalDateTime();
}
return LocalDateTime.parse(s.replace(" ", "T"));
} catch (Exception e) {
return null;
}
return null;
}
}