YYYY DateTime Problem in Java

See this code of datetime in java

SimpleDateFormat format = new SimpleDateFormat("dd-MMM-YYYY");

Calendar day1 = new GregorianCalendar(2014, Calendar.DECEMBER, 28);
System.out.println(format.format(day1.getTime()));

Calendar day2 = new GregorianCalendar(2014, Calendar.DECEMBER, 29);
System.out.println(format.format(day2.getTime()));

This is what you get in console :

28-Dec-2015
29-Dec-2015

WTH!!!!!!!!!!!!!!!!!!!!!!!!!
But this problem doesn’t happen in Joda Time

And this is why all twitter account in android is force sign out by twitter. According to this, it says “Values calculated for the WEEK_OF_MONTH field range from 0 to 6. Week 1 of a month (the days with WEEK_OF_MONTH = 1) is the earliest set of at least getMinimalDaysInFirstWeek() contiguous days in that month, ending on the day before getFirstDayOfWeek(). Unlike week 1 of a year, week 1 of a month may be shorter than 7 days, need not start on getFirstDayOfWeek(), and will not include days of the previous month. Days of a month before week 1 have a WEEK_OF_MONTH of 0.

For example, if getFirstDayOfWeek() is SUNDAY and getMinimalDaysInFirstWeek() is 4, then the first week of January 1998 is Sunday, January 4 through Saturday, January 10. These days have a WEEK_OF_MONTH of 1. Thursday, January 1 through Saturday, January 3 have a WEEK_OF_MONTH of 0. If getMinimalDaysInFirstWeek() is changed to 3, then January 1 through January 3 have a WEEK_OF_MONTH of 1.”

 
7
Kudos
 
7
Kudos

Now read this

SRM 629 Div 2 1000 Points

If you are following the topcoder SRM 629 div 2 this is the source code public class CandyAddict { public static void main(String[] args) { solve(new int[]{1000000000,1000000000,1000000000,1000000000,1000000000}, new... Continue →