I have this Date value in angular 6 application:
expires_at: Date;
In Java getter I use String to get the value:
private String expires_at;
But when I convert using this code:
From String to LocalDateTime
terminals.setExpires_at(LocalDateTime.parse(terminalDTO.getExpires_at()));
From LocalDateTime to String:
terminalNewDTO.setExpires_at(DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(terminals.getExpires_at()));
I get this error:
create] due to exception [Text '2019-02-19T01:00:00.000Z' could not be parsed, unparsed text found at index 23]
20:55:43,494 INFO [stdout] (default task-1) java.time.format.DateTimeParseException: Text '2019-02-19T01:00:00.000Z' could not be parsed, unparsed text found at index 23
20:55:43,494 INFO [stdout] (default task-1) at java.base/java.time.format.DateTimeFormatter.parseResolved0(DateTimeFormatter.java:2049)
20:55:43,494 INFO [stdout] (default task-1) at java.base/java.time.format.DateTimeFormatter.parse(DateTimeFormatter.java:1948)
20:55:43,495 INFO [stdout] (default task-1) at java.base/java.time.LocalDateTime.parse(LocalDateTime.java:492)
20:55:43,495 INFO [stdout] (default task-1) at java.base/java.time.LocalDateTime.parse(LocalDateTime.java:477)
20:55:43,496 INFO [stdout] (default task-1) at deployment.datalis_admin.war//org.datalis.admin.backend.mapper.TerminalsMapperImpl.map(TerminalsMapperImpl.java:98)
20:55:43,496 INFO [stdout] (default task-1) at deployment.datalis_admin.war//org.datalis.admin.backend.restapi.TerminalController.create(TerminalController.java:104)
20:55:43,496 INFO [stdout] (default task-1) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
20:55:43,497 INFO [stdout] (default task-1) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
20:55:43,497 INFO [stdout] (default task-1) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
20:55:43,497 INFO [stdout] (default task-1) at java.base/java.lang.reflect.Method.invoke(Method.java:566)
20:55:43,497 INFO [stdout] (default task-1) at deployment.datalis_admin.war//org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:189)
Do you know how I can solve this issue?
This is the date value: 2/20/19, 3:00 AM
which I try to send.
from Convert Date from angular to Java
No comments:
Post a Comment