-
Hello everyone, I hope you are all doing well. I'm currently facing an issue with the "parse-time" function, and I'm reaching out to anyone who can help me understand this problem better. The "parse-time" function is intended to parse dates in a specified format and return a timestamp. However, I've encountered unexpected behavior in my use case. For instance, when I use the function like this:
The result is 0.0. However, when I use the function like this:
The result is -345600.0. Please note the difference between the year format, specifically the uppercase "Y" in the second example. My question is whether this behavior is normal, or if it might be an implementation problem. I would greatly appreciate any insights or guidance on this matter. Thank you for your time and support. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This was a slightly tricky one to figure out. The JSLT implementation uses For So this is not a bug in JSLT, nor one in Java. My recommendation to you is: don't ever touch the |
Beta Was this translation helpful? Give feedback.
This was a slightly tricky one to figure out. The JSLT implementation uses
SimpleDateFormat
, wherey
is defined as "year", andY
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 givesMon 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.