How to convert dd/MM/yyyy HH:mm:ss to offsetdatetime - java

Luis Marcelo Santos :

I upgraded to:

DateTimeFormatter dtf = DateTimeFormatter.ofPattern ("dd/MM/yyyy HH:mm:ss");
org.threeten.bp.LocalDateTime _date = org.threeten.bp.LocalDateTime.parse ("10/19/2020 18:00:47", dtf);

and get: 2020-10-19T18:00:47 but I still don't have an exit with the standard: 2020-10-19T18:00:47.868-03:00

user3197884 :

Your DateTimeFormatter has ("dd/MM/yyyy HH:mm:ss") but you have used "10/19/2020 18:00:47". Month cannot be 19.

Change your input to "19/10/2020 18:00:47" and it should work.

org.threeten.bp.format.DateTimeFormatter dtf = org.threeten.bp.format.DateTimeFormatter.ofPattern ("dd/MM/yyyy HH:mm:ss");
org.threeten.bp.LocalDateTime _date = org.threeten.bp.LocalDateTime.parse("19/10/2020 18:00:47", dtf);
System.out.println(_date);

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=30376&siteId=1