java left logo
java middle logo
java right logo
 

Home arrow Java SE Tips arrow java.util arrow Determine the day of the week
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 4100
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
Determine the day of the week E-mail
User Rating: / 14
PoorBest 

This tip shows the ways to determine the day of the week in Java.

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(199721000);
// 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 )           
*/

 Related Tips

 
< Prev   Next >
 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.