Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Local Date Parsing 2021-06-07+03:00

How can I parse this Date?

DateTimeParseException: Text ‘2021-06-07+03:00’ could not be parsed at index 10

I have tried both DateTimeFormatter.ISO_ZONED_DATE_TIME and DateTimeFormatter.ofPattern("yyyyMMdd"). these are not work.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Do u you have any suggestions?

>Solution :

May be something like this?

String dt="2021-06-07+03:00";
DateTimeFormatter dateTimeFormatter= DateTimeFormatter.ISO_DATE;
System.out.println(dateTimeFormatter.parse(dt).get(ChronoField.OFFSET_SECONDS));
System.out.println(dateTimeFormatter.parse(dt).get(ChronoField.DAY_OF_YEAR));

Output:

Offset seconds: 10800
Day of year:158
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading