• 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

How to compare 2 Dates in String Format

 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi buddies
My target is to compare two dates, which are in String format. The Possible String formats are
"10-OCT-2002" and "10-10-2002".
Please guide me which class should i use, in order to get the my string converted to date,
AND
Which functions should i use, So that i can compare (less than, greater than comparision) two dates (converted above with the help of some xyz class)
Please guide me at your earliest....

Regards
Manish
[ August 27, 2002: Message edited by: Manish Sachdev ]
[ August 28, 2002: Message edited by: Manish Sachdev ]
[ August 28, 2002: Message edited by: Manish Sachdev ]
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take a look at http://jinx.swiki.net/223 (and don't hesitate to augment it - it's editable for everyone).
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about
SimpleDateFormat formatter = new SimpleDateFormat ("[yy.MM.dd hh:mm:ss:SSS zz]");
Date currentTime_1 = new Date();
String date = formatter.format(currentTime_1);
Have a look at the SimpleDateFormat on how to format the date time differently.
 
M Sharma
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Jonathan and Ilja for the effort taken by you to help me out,
But the information provided by you is not helping me completely,
Can you please provide me the code for the task, which i need to acheive.
1)I have two dates :
"10-JAN-1920" and "10-APR-1950",
2) Please provide me the code to convert the above dates to String and After conversion, compare the above two dates which can tell me that the first date is greater than the second one.....
I hope, that you understand the problem i am facing......
I want both the above things to be accomplished

Waiting for a solution...
[ August 28, 2002: Message edited by: Manish Sachdev ]
[ August 28, 2002: Message edited by: Manish Sachdev ]
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

 
M Sharma
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jamie,
Thanks for the efforts that you have taken to help me out. This was the exact thing which i needed.......
Thank you very Much....
Regards
Manish
 
He baked a muffin that stole my car! And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic