3 ms·
You 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() +
by Sharlin 10y ago
You 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.