• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Date; Previous date, Calendar; Gregorian

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ur java date is very good- how about date in words?
 
A lot of people cry when they cut onions. The trick is not to form an emotional bond. This tiny ad told me:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic