aspose file tools*
The moose likes Java in General and the fly likes Date; Previous date, Calendar; Gregorian Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Date; Previous date, Calendar; Gregorian" Watch "Date; Previous date, Calendar; Gregorian" New topic
Author

Date; Previous date, Calendar; Gregorian

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Jun 13, 2000
Posts: 3340
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).]


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944

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

Joined: Jul 24, 2006
Posts: 1
ur java date is very good- how about date in words?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Date; Previous date, Calendar; Gregorian
 
Similar Threads
Problems in converting to a Date Object.
I Seriously Need Helps.. Ugently
Compare Dates sans Time Fields
Problems in converting to a Date Object.
Date help