Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dates 2

Status
Not open for further replies.

joelmac

Programmer
Jun 4, 2002
92
CA
what's the easiest way to manipulate dates?? I can't make heads or tails of the java doc's. is there another source that explains the whole in an easy to understand way??

All i want is to get the day of the week (1-7) that the current month starts on.

am i just an idiot? does anyone else have trouble with dates?? ________________________
JoelMac
ICQ#:48144432
 
Dates do tend to confuse some people. Before Java 1.2 all date manipulation happened on java.util.Date objects. Now, in Java 2, all date manipulation happens with java.util.Calendar classes. Here of getting the day of the week that July 2002 starts on:
Code:
Calendar cal = Calendar.getInstance();
cal.set(2002,Calendar.JULY, 1);
int day = cal.get(Calendar.DAY_OF_WEEK);
Word of warning: most things in Calendar are zero based even if they are not normally represented as such. For example, Calendar.JANUARY == 0 instead of 1 like most people think. The days of the week are indexed at 0 also. Try to use the constants defined in the Calendar class whenever possible to make your code cleaner and easier to read.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top