Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How is a function that converts an internal date/time representation to an external/string-based one not "date/time stuff", regardless of the package it happens to be in?


You may want to check out the contents of java.time [1] and it's subpackages to see what I mean by stuff.

[1] https://docs.oracle.com/en/java/javase/17/docs/api/java.base...


java.time.format.DateTimeFormatter seems to still point the exact same loaded footgun (i.e. the format patterns "Y" and "y") at every junior developer that dares to use it, so I'm not sure that would have helped junior-me much.

The important information I was missing was "the week-based year and the year-of-era representations of one and the same date differ on some days, but not all days, and especially not those days you're currently using in your unit tests".

And even if it wouldn't – SimpleDateTime was the non-deprecated standard library method I found at the time that seemed to do my job, so that was the one I used.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: