-5
Calendar cal = new GregorianCalendar();

If I want to know the date after 3 days from "cal", is there a way to compute that? Thanks. Can the add(int field, int amount) method do that?

Carl Manaster
  • 39,912
  • 17
  • 102
  • 155
user697911
  • 10,043
  • 25
  • 95
  • 169
  • 3
    Before asking it is always a good idea to search the site (or the whole internet) and also read the official documentation, otherwise you might find your question gets downvoted. – Matt Coubrough Jul 09 '14 at 00:39
  • possible duplicate of [How to add one day to a date?](http://stackoverflow.com/questions/1005523/how-to-add-one-day-to-a-date) – Basil Bourque Jul 09 '14 at 07:35

2 Answers2

0

If I understand your question, then yes. Using Calendar.DAY_OF_MONTH

Calendar cal = new GregorianCalendar();
cal.add(Calendar.DAY_OF_MONTH, 3);
Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249
0

Indeed, you can get the date from a Calendar object:

Calendar cal = new GregorianCalendar()
Date d;
cal.add(Calendar.DATE, 3);
d = cal.getTime();
Barranka
  • 20,547
  • 13
  • 65
  • 83