H
hemant.singh
please run the following code
Here im creating a GregorianCalendar instance and than add one 27 times
to DAY_OF_MONTH and to my surprise it will show you 31st feb 2006
before moving to march, ,this is really crazy, any1 know of workaround?
public static void main(String[] args)
{
System.out.println("Hello World!");
Calendar calNow = new GregorianCalendar();
String WEEK[] = {"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"};
String MONTH[] = {"January", "Feburary", "March", "April", "May",
"June", "July", "August", "September", "October", "November",
"December"};
String[] options = new String[27];
long values[] = new long [ options.length ];
for (int i = 0; i < options.length; i++ ) {
values = calNow.getTimeInMillis();
options = WEEK[calNow.get(Calendar.DAY_OF_WEEK) - 1]+
", " + calNow.get(Calendar.DAY_OF_MONTH) +
" " + MONTH[ calNow.get(Calendar.MONTH) - 1] +
" " + calNow.get(Calendar.YEAR) ;
calNow.add(Calendar.DAY_OF_MONTH,1);
}
for (int i = 0;i < options.length; i++ )
{
System.out.println(options);
}
}
Here im creating a GregorianCalendar instance and than add one 27 times
to DAY_OF_MONTH and to my surprise it will show you 31st feb 2006
before moving to march, ,this is really crazy, any1 know of workaround?
public static void main(String[] args)
{
System.out.println("Hello World!");
Calendar calNow = new GregorianCalendar();
String WEEK[] = {"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"};
String MONTH[] = {"January", "Feburary", "March", "April", "May",
"June", "July", "August", "September", "October", "November",
"December"};
String[] options = new String[27];
long values[] = new long [ options.length ];
for (int i = 0; i < options.length; i++ ) {
values = calNow.getTimeInMillis();
options = WEEK[calNow.get(Calendar.DAY_OF_WEEK) - 1]+
", " + calNow.get(Calendar.DAY_OF_MONTH) +
" " + MONTH[ calNow.get(Calendar.MONTH) - 1] +
" " + calNow.get(Calendar.YEAR) ;
calNow.add(Calendar.DAY_OF_MONTH,1);
}
for (int i = 0;i < options.length; i++ )
{
System.out.println(options);
}
}