This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes How to compare date in this format:4/8/02 8:47 AM? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to compare date in this format:4/8/02 8:47 AM?" Watch "How to compare date in this format:4/8/02 8:47 AM?" New topic
Author

How to compare date in this format:4/8/02 8:47 AM?

Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
How to compare date in this format:4/8/02 8:47 AM?
Thanks


Thanks everyone who helped me
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

Compare it to what? Generally, you can use DateFormat to convert the string to a Date and then perhaps to a long. From there you should be able to do whatever you want.
hth,
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Steve Deadsea
Ranch Hand

Joined: Dec 03, 2001
Posts: 125
Specifically, you probably want to use SimpleDateFormat sdf = SimpleDateFormat("MM/dd/yy hh:mm aa");
to parse the date into a Java Date object:
Date d = sdf.parse("4/8/02 8:47 AM");
Then compare it to another Date:
d.after(new Date());
 
wood burning stoves
 
subject: How to compare date in this format:4/8/02 8:47 AM?