Skip to content

Date parsing problem #312

Answered by larsga
PieroM97 asked this question in Q&A
Oct 20, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

This was a slightly tricky one to figure out. The JSLT implementation uses SimpleDateFormat, where y is defined as "year", and Y as "week year". What is "week year"? Almost certainly not what you think.

For "1970-01-01" your first format string gives the expected result, but the second one gives Mon Dec 29 00:00:00 CET 1969. I think this is because that's the first day of the first week of 1970.

So this is not a bug in JSLT, nor one in Java. My recommendation to you is: don't ever touch the Y format code. Just stay away from it.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@PieroM97
Comment options

Answer selected by PieroM97
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants