Hi,
i need a calendar function in my app, but i have problems to
determinate the day of the week from the chosen Date. I tried much and
it seems like a bug to me. Here's the code:
TimeZone zone = TimeZone.getDefault();
GregorianCalendar calendar = new GregorianCalendar(zone);
calendar.set( 2009 , 6 , 1);
if( calendar.get(Calendar.DAY_OF_WEEK) == calendar.get
(Calendar.MONDAY) ){
System.out.println("MONDAY!");
} else if (calendar.get(Calendar.DAY_OF_WEEK) == calendar.get
(Calendar.TUESDAY) ){
System.out.println("TUESDAY!");
} else if (calendar.get(Calendar.DAY_OF_WEEK) == calendar.get
(Calendar.WEDNESDAY) ){
System.out.println("WEDNESDAY!");
} else if (calendar.get(Calendar.DAY_OF_WEEK) == calendar.get
(Calendar.THURSDAY) ){
System.out.println("THURSDAY!");
} else if (calendar.get(Calendar.DAY_OF_WEEK) == calendar.get
(Calendar.FRIDAY) ){
System.out.println("FRIDAY!");
} else if (calendar.get(Calendar.DAY_OF_WEEK) == calendar.get
(Calendar.SATURDAY) ){
System.out.println("SATURDAY!");
} else if (calendar.get(Calendar.DAY_OF_WEEK) == calendar.get
(Calendar.SUNDAY) ){
System.out.println("SUNDAY!");
}
It prints Saturday, actually June the first is a Monday.
I tried other values:
calendar.set( 2009 , 7 , 1); prints Monday, but is actually a
Wednesday
calendar.set( 2009 , 8 , 1); -> Saturday, correct
calendar.set( 2009 , 9 , 1); -> Saturday, should be tuesday
calendar.set( 2009 , 10 , 1); -> Wednesday , should be a Thursday
Does anyone know what's wrong here? Thanks in advance
Regards, Pascal
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---