Every time I need to work with date and/or timstamps in Java I always feel like I’m doing something wrong and spend endless hours trying to find a better way of working with the APIs without having to code my own Date and Time utility classes. Here’s a couple of annoying things I just ran into:
-
0-based months. I realize that best practice is to use Calendar.SEPTEMBER instead of 8, but it’s annoying that 8 represents September and not August.
-
Getting a date without a timestamp. I always need the utility that Zeros out the timestamp portion of the date.
-
I know there’s other issues I’ve had in the past, but can’t recall. Feel free to add more in your responses.
So, my question is … What third party APIs do you use to simplify Java’s usage of Date and Time manipulation, if any? Any thoughts on using Joda? Anyone looked closer at JSR-310 Date and Time API?
This post has a good discussion on comparing the Java Date/Time API vs JODA.
I personally just use Gregorian Calendar and SimpleDateFormat any time I need to manipulate dates/times in Java. I’ve never really had any problems in using the Java API and find it quite easy to use, so have not really looked into any alternatives.