I was testing this Scripting Function in the Script Console and I am getting some bad results.
Does anyone have any idea about what I'm doing wrong here:
d1 = system.date.format(system.date.now(), "YYYY-MM-dd HH:mm:ss.SSS")
d2 = system.date.parse(d1, "YYYY-MM-dd HH:mm:ss.SSS")
What are you actually trying to accomplish?
You're just getting confused over the string representation.
d1 is a String you've formatted a Date object into. You chose the format of that string.
d2 is Date object you've parsed from
d1, being displayed using the built-in
toString() representation. The Date object displays itself differently than the format you parsed the original date into.
The problem that I noticed is that the date value is different, the day and month, specifically.
Use lower-case 'y':
d1 = system.date.format(system.date.now(), "yyyy-MM-dd HH:mm:ss.SSS")
d2 = system.date.parse(d1, "yyyy-MM-dd HH:mm:ss.SSS")
upper-case 'Y' is for "week years", which is still not a thing I actually understand.