Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Months and years

 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way in Java to get future month informtaion? Such as, what day of the week is August 15th 2003 going to be. I'm looking at the Calendar class to see if that might provide a way.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look into SimpleDateFormat in the API to get the 'patterns' you can use to format a date...

I believe the code below is a quick and dirty ( no error checking ) solution... just run the program, passing in a command-line argument in the form of mm/dd/yyyy, where mm is the month, dd is the day, and yyyy is the year. The program will return the day of the week that date is...



HTH,
-Nate
[This message has been edited by Nathan Pruett (edited July 10, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic