Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
-
None
-
Operating System: Windows XP
Platform: PC
-
33102
Description
There is no way to do Date arithmetic in one line in Java, unless you use
deprecated methods. The following method initializes a Calendar object with a
date and performs date arithmetic on it, and returns the result as a java.util.Date.
public static Date add(Date date, int field, int amount)
{ Calendar c = new GregorianCalendar(); c.setTime(date); c.add(field, amount); return c.getTime(); }