Код: Выделить всё
@XmlJavaTypeAdapter(LocalDateTimeAdapter.class)
private LocalDateTime mydate;
Код: Выделить всё
...
2025-10-15 09:49:54
...
Код: Выделить всё
Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `java.time.LocalDateTime` from String "2025-10-15 09:49:54"
Как настроить Spring Boot для использования моего адаптера JaxB?
Вот мой адаптер:
Код: Выделить всё
public class LocalDateTimeAdapter extends XmlAdapter {
private static final DateTimeFormatter STANDARD_DATETIME_PATTERN = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
public LocalDateTime unmarshal(String value) {
try {
return LocalDateTime.parse(value, STANDARD_DATETIME_PATTERN);
} catch (Exception e) {
throw new MyException(e.getMessage(), e);
}
}
public String marshal(LocalDateTime localDateTime) {
try {
return localDateTime.format(STANDARD_DATETIME_PATTERN);
} catch (Exception e) {
throw new MyException(e.getMessage(), e);
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... ypeadapter
Мобильная версия