• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date Conversion...

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could anyone help me on this, i am trying to get the difference between the system date and the date i have stored as a String object("12-Aug-99"). I am using Calendar class to get the current date.
 
paul wheaton
Trailboss
Pie
Posts: 21390
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since this doesn't seem to have anything to do with certification, I'm gonna move this to the Java in General (beginner) forum so more people might be able to answer it.
 
paul wheaton
Trailboss
Pie
Posts: 21390
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because the built in Date classes have some issues, I made my own date handling classes. See www.javaranch.com/common.html. Look for GDate and JDate.
String s = "1999-08-12"; // aug 12, 99
int todayInt = new JDate( new GDate() ).get();
int prevInt = new JDate( new GDate( s ) ).get();
int diff = todayInt - prevInt ;
I hope this helps.
[This message has been edited by Marilyn deQueiroz (edited September 26, 2001).]
 
Ronald Whalen
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul,
I tried your link but it was not found. Your classes sound like just what I need. Is there another link?

Ronald
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ronald. Remove the . at the end of the address.
 
Ivan Tamayo
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may use GregorianCalendar.
 
Art Metzer
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try something like this:

Good luck to you,
Art
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic