Skip to content

Add Instant support for dateFormat#866

Merged
jknack merged 1 commit intojknack:masterfrom
ydylla:improve-date-format
Sep 25, 2021
Merged

Add Instant support for dateFormat#866
jknack merged 1 commit intojknack:masterfrom
ydylla:improve-date-format

Conversation

@ydylla
Copy link
Contributor

@ydylla ydylla commented Aug 17, 2021

This adds support for more date types like Instant, OffsetDateTime, LocalDateTime for the dateFormat string helper.

Closes #839

* add support for more date types like Instant, OffsetDateTime, LocalDateTime, ...
@jknack jknack added this to the 4.2.1 milestone Sep 25, 2021
@jknack jknack merged commit 40ca09a into jknack:master Sep 25, 2021
@dontgitit
Copy link

FWIW, while I think overall this is a positive change, I think it is not backwards compatible, as it seems to replace SimpleDateFormat with DateTimeFormatter, which produces different output for the same formats.

for one example, see https://stackoverflow.com/questions/36722873/datetimeformatter-not-compatible-with-simpledateformat
for another, using the date represented by 2018-01-08 12:30:05 -0800, the format for the day of week in month - {{dateFormat date format="F" tz="UTC"}} - used to produce 2, but with this change, it produces 1

@ydylla
Copy link
Contributor Author

ydylla commented Aug 9, 2022

Thanks for pointing this out, I was not aware of this.
These seam to be the patterns that changed in meaning completely, aside from potential formatting differences:

Pattern SimpleDateFormat DateTimeFormatter
F Day of week in month week-of-month (only according to Java 8 docs)
u Day number of week year

Edit: DateTimeFormatter F seams to change definition between Java 8 & 11 from week-of-month to day-of-week-in-month thus matching SimpleDateFormat. I did not test any of this, just reading the linked docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for newer java.time types in StringHelpers

3 participants