by hn_throwaway_99 · 9y ago · 0 comments
Of course, as the article and other commenters have said, just use jodatime or the Java 8 equivalent.
If a function accepts a java.util.Date and you pass an id of some database object by mistake, you'll get a compile error. If the function accepts a long you won't.
If a function accepts a java.util.Date and the parameter is called "start" you know it accepts an instant in time, if it accepts a long you might think it could be something else.
Yes, the class is terribly named, but before there was Java 8 and Jodatime, it was better to use it than a long.
Don't do java.util.Date.
date.setMonth(date.getMonth() + 1);
and it will do the Right Thing even if the month is December.I've written all of date arithmetic using only long values and I can share the code if anyone is interested