• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Ken Shamrock
Ranch Hand
Posts: 139
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to compare date in this format:4/8/02 8:47 AM?
Thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64181
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Steve Deadsea
Ranch Hand
Posts: 125
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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());
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic