Forum Stats

  • 3,724,396 Users
  • 2,244,746 Discussions


Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

SimpleDateFormat like parsing behavior with DateTimeFormatter?

steffi Member Posts: 140 Blue Ribbon

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 '.'

Sign In or Register to comment.