Reputation: 4741
Date toDate = new Date(114, 5, 30);
Calendar calendar = Calendar.getInstance();
Calendar calendarTo = Calendar.getInstance();
calendar.setTime(toDate);
calendarTo.setTime(toDate);
calendarTo.add(Calendar.DATE, 1);
this is how I initialize calendars and I am trying to put NEXT day in calendarTo but when I getting calendar.Date it is equal to calendarTo.DATE and is equal to 5.. why? And how I could finally increment this DATE value?
Upvotes: 0
Views: 38
Reputation: 3649
What you are getting is the default value of DATE in Calendar class. Which is 5
public final static int DATE = 5;
But when I print the dates from your code, looks like it is fine.
Date toDate = new Date(114, 5, 30);
Calendar calendar = Calendar.getInstance();
Calendar calendarTo = Calendar.getInstance();
calendar.setTime(toDate);
calendarTo.setTime(toDate);
calendarTo.add(Calendar.DATE, 1);
System.out.println(toDate);//Mon Jun 30 00:00:00 IST 2014
System.out.println(calendarTo.getTime());//Tue Jul 01 00:00:00 IST 2014
Upvotes: 1