3 ms·
The java.util.Date API is pretty clearly modeled off of POSIX time, and therefore retains compatibility with POSIX's wrong decisions. I suspect that POSIX used
by jcranmer 10y ago
The java.util.Date API is pretty clearly modeled off of POSIX time, and therefore retains compatibility with POSIX's wrong decisions. I suspect that POSIX used 0-based months so they could index into some const char *monthNames[]; variable; since years and days are shown directly, there's no need to force them to be 0-based (not that day-of-week and day-of-year are 0-based as well).
- Clownshoesms 10y agoI didn't realize that came from POSIX or was an attempt at complying with it. Yes the array indice makes sense (although exposing that externally and not just adjusting the value internally seems like a poor decision). Not sure why Java felt the need to carry that behaviour across, I can't recall anyone clammering for POSIX compliant date handling.