3

Possible Duplicate:
How to get date of last Friday from specified date?

Using java.util.Calendar (or any other library), is there a way i can find out what the Date of what Month of what Year was "Friday 2 weeks ago"?

Please advise

Community
  • 1
  • 1
James Raitsev
  • 92,517
  • 154
  • 335
  • 470
  • Check here - http://stackoverflow.com/questions/5944760/how-to-get-date-of-last-friday-from-specified-date. – Perception Jul 05 '11 at 15:07

1 Answers1

5

Try this way:

Calendar vCal = Calendar.getInstance();
vCal.add(Calendar.WEEK_OF_YEAR, -2); //two weeks ago
vCal.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY); //friday

int vDay = vCal.get(Calendar.DAY_OF_MONTH); //day
int vMonth = vCal.get(Calendar.MONTH); //month
int vYear = vCal.get(Calendar.YEAR); //year

Date d = vCal.getTime(); //full date

Good luck.

Andrei Petrenko
  • 3,922
  • 3
  • 31
  • 53