Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

SimpleDateFormat like parsing behavior with DateTimeFormatter?

steffiMar 4 2021

In a particular case I observe that SimpleDateFormat will only parse up to the format you've specified even if the String is longer. so if a timestamp contains milliseconds and your format string ends with seconds it will only parse up until and including the seconds.
With DateTimeFormatter it seems to keep parsing and consequently you end up retaining the milliseconds in your LocalDateTime
Is there a way to configure DateTimeFormatter so that it only parses what's defined in the format string even when the String contains content after the '.'

Comments

Jose Cruz

Dear Friend

You could see examples at this blog

1 - 1

Post Details

Added on Mar 4 2021
0 comments
93 views