Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date; Previous date, Calendar; Gregorian

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good day everyone.
I am somewhat stuck on something that seems so simple.
Q: I am trying to write a small app. which will accept the current day of a year and output the correct previous day and DATE. This should take into regards Leap year difference and anything else. I'd like to be able to do this possibly using 1 or a few of the methods that the Java API offers. Any assistance on this would be greatly appreciated.
Thanks
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This isn't as easy as it may look at first, Ther isn't an easy way to creat a Calendar or GregorianCalendar object from a string and any method to change a date is depricated. After some study a possible solution is :

The output is now
Enter a Date in mm/dd/yyyy format
03/01/2000
Todays Date = 03/01/2000
Yesterdays Date = 02/29/2000
-and-
Enter a Date in mm/dd/yyyy format
03/01/1900
Todays Date = 03/01/1900
Yesterdays Date = 02/28/1900
-and-
Enter a Date in mm/dd/yyyy foramt
01/01/2000
Todays Date = 01/01/2000
Yesterdays Date = 12/31/1999

This is better I hope


[This message has been edited by Carl Trusiak (edited September 22, 2000).]
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Carl,
Thank you very much. I appreciate this. I had 1st thought it
was quite simple, but as I looked at it more closely, I saw
small problems. I suppose I was hoping for a buildt method
within the java.util.Date or Calendar classes for automatically
being able to convert dates. And even when I did mess around
with the logic, I ended up solving most of the problems but
leaving behind a few critical points. Thank you very much.
Feel free to ask any Qs as well.

Saurav
 
Darwin Perez
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ur java date is very good- how about date in words?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic