5 ms·
Yeah. Have fun working out date arithmetic, leap seconds and time zones on your own. What could possibly go wrong.
by Tharkun 10y ago
Yeah. Have fun working out date arithmetic, leap seconds and time zones on your own. What could possibly go wrong.
- kpil 10y agoNo, that would be stupid - but you can't use a Date for that either.
- Sharlin 10y agoYou can; there are getters and setters for the different components. And because Date is lenient by default, you can do eg. date.setMonth(date.getMonth() + 1); and it will do the Right Thing even if the month is December.
- jdmichal 10y agoThe `get` and `set` methods on `Date` have been deprecated since 1.1... In favor of `Calendar`, which is all `Date` is using under the hood to perform such calculations anyway.
- Sharlin 10y agoTrue that, somehow totally slipped from my mind. To my defense, the last few times I've used java.util.Date it has been with GWT which doesn't provide anything better at least out of the box.
- jdmichal 10y agoNo worries. The whole thing was a tire-fire from the get-go, and I certainly don't blame you.
- bluestreak 10y agoIt should be encouraged to use long. Not only it performs better, but it is also simpler to understand and use compared to obscurity of java.util.Date. I've written all of date arithmetic using only long values and I can share the code if anyone is interested