Java Date

I need a utility class which returns a previous date from current date, for example
   i) a date of before seven days/week days to currentdate
  ii) a date before one month to current date
  ii) a date before one year to current date.

It has to take consideration of all, whether 28 days or 29 days or 30 days or 31 days in a month or whether its a leap year or not...and all.

I need it with code. Can anyone guide me where can i get that class.

vinayknAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
giamtrotConnect With a Mentor Commented:
Just to add an example:

Date startingDay = ...

// Contains date of now
GregorianCalendar gc = new GregorianCalendar();

// Now Contains startindDay
gc.setTime(startingDay);

// A week has passed
gc.add( java.util.Calendar.DATE, 7);

// Go back in time
gc.add( java.util.Calendar.MONTH, -7);

// Retrieve the day we've got
Date endingDay = gc.getTime();

and so on ...

0
 
giamtrotCommented:
The java.util.GregorianCalendar add method does all of this.
0
 
ValeriCommented:
listening
0
 
vinayknAuthor Commented:
Thank you verymuch Trot....
0
All Courses

From novice to tech pro — start learning today.