2

hii all I have date in string form I want to convert it into first date form and increase date to one like

12-12-2000

to

13-12-2000

and want to re convert that increased date to string

codaddict
  • 445,704
  • 82
  • 492
  • 529
HBK
  • 55
  • 1
  • 10
  • possible duplicate of [How can I increment a date by one day in Java?](http://stackoverflow.com/questions/428918/how-can-i-increment-a-date-by-one-day-in-java) – dogbane Jan 24 '11 at 08:21

2 Answers2

1

I think this will work

String date = "2011-05-01"; 
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
c.setTime(df.parse(date));
c.add(Calendar.DATE, 1);  // how many days you want to add like here 1
String addeddate = df.format(c.getTime());  
ayush
  • 14,350
  • 11
  • 53
  • 100
0
  1. DateFormat for parsing and formatting. Example
  2. Calendar.roll(...) for date arithmetic. Example

NOTE: Do not forget setLenient(true). Example

Aravind Yarram
  • 78,777
  • 46
  • 231
  • 327