Determine to day of the weekTag(s): Date and Time


For the day of the week for today :
GregorianCalendar newCal = new GregorianCalendar( );
int day = newCal.get( Calendar.DAY_OF_WEEK );
For the day of the week for any date :
Calendar newCal = new GregorianCalendar();
newCal.set(1997, 2, 1, 0, 0, 0);
// BUG fix in Calendar class!
newCal.setTime(newCal.getTime());    
int day = newCal.get(Calendar.DAY_OF_WEEK);
/*  
 also available :
   newCal.get( Calendar.DAY_OF_MONTH )
   newCal.get( Calendar.DAY_OF_WEEK_IN_MONTH )
   newCal.get( Calendar.DAY_OF_YEAR )      
   newCal.get( Calendar.DATE )           
*/

blog comments powered by Disqus