hii all I have date in string 开发者_JAVA技巧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
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());
- DateFormat for parsing and formatting. Example
- Calendar.roll(...) for date arithmetic. Example
NOTE: Do not forget setLenient(true). Example
精彩评论