Преобразование формата Luxon DateTime ISO в Java LocalDateTime ⇐ JAVA
-
Гость
Преобразование формата Luxon DateTime ISO в Java LocalDateTime
My frontend vue application sends a luxon DateTime object to a Spring Boot backend which has a LocalDateTime field, however, java is unable to parse the DateTime object. I have tried using both luxon's toSQL() and toISO() methods to format, but of no avail.
What would be the optimal way of sending date time from a vue application to a java backend?
example request:
"date_deadline": "2024-03-07 14:54:51.440 +08:00" The java entity looks as follows:
@Entity @Table(name = "todos") public class Todo { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") private Long id; private LocalDateTime date_created; @Column (name = "date_deadline") @Temporal(TemporalType.TIMESTAMP) private LocalDateTime date_deadline; } When passing the json in the request body, I get the following 400 response:
"message": "JSON parse error: Cannot deserialize value of type `java.time.LocalDateTime` from String \"2024-03-07 14:54:51.440 +08:00\": Failed to deserialize java.time.LocalDateTime: (java.time.format.DateTimeParseException) Text '2024-03-07 14:54:51.440 +08:00' could not be parsed at index 10",
Источник: https://stackoverflow.com/questions/781 ... aldatetime
My frontend vue application sends a luxon DateTime object to a Spring Boot backend which has a LocalDateTime field, however, java is unable to parse the DateTime object. I have tried using both luxon's toSQL() and toISO() methods to format, but of no avail.
What would be the optimal way of sending date time from a vue application to a java backend?
example request:
"date_deadline": "2024-03-07 14:54:51.440 +08:00" The java entity looks as follows:
@Entity @Table(name = "todos") public class Todo { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") private Long id; private LocalDateTime date_created; @Column (name = "date_deadline") @Temporal(TemporalType.TIMESTAMP) private LocalDateTime date_deadline; } When passing the json in the request body, I get the following 400 response:
"message": "JSON parse error: Cannot deserialize value of type `java.time.LocalDateTime` from String \"2024-03-07 14:54:51.440 +08:00\": Failed to deserialize java.time.LocalDateTime: (java.time.format.DateTimeParseException) Text '2024-03-07 14:54:51.440 +08:00' could not be parsed at index 10",
Источник: https://stackoverflow.com/questions/781 ... aldatetime
Мобильная версия