aspose file tools*
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 Spring in Action this week in the Spring 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: 61433
    
  67

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());
 
Consider Paul's rocket mass heater.
 
subject: How to compare date in this format:4/8/02 8:47 AM?