문제
this.checkIn = room.getCheckIn().format(DateTimeFormatter.ofPattern("HH:MM"));
this.checkOut = room.getCheckOut().format(DateTimeFormatter.ofPattern("HH:MM"));
c.a.global.error.GlobalExceptionHandler : Unsupported field: MonthOfYear
java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: MonthOfYear
문제해석
room의 checkIn과 checkOut이 LocalTime이지만, HH:MM 포맷인 String type으로 바꿔서 받고싶은 경우 발생한 에러
해결방안
-
DateTimeFormatter.ofPattern("HH:MM")
에서 사용한 패턴 문자열의 문제점⇒ 올바른 패턴 문자열
“HH:mm”
- “MM”은 월(month)를 나타내기 때문에, 분을 나타내려면 “mm”을 사용해야한다.
this.checkIn = room.getCheckIn().format(DateTimeFormatter.ofPattern("HH:mm"));
this.checkOut = room.getCheckOut().format(DateTimeFormatter.ofPattern("HH:mm"));
Uploaded by N2T