Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String to Java Date

 
Drew Lane
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a string that is in a date format: 08/13/02
How would I convert this to a Java date object so that I can use Java Methods to manipulate the date?
Thanks,
Drew
 
john guthrie
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
see java.text.DateFormat, specifically something like:
DateFormat parser = DateFormat.getDateInstance(DateFormat.SHORT);
Date d = parser.parse("12/22/97");
 
Drew Lane
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I'll give that a try.
I didn't know DateFormat could parse, too.
So much to learn, so little time...
Drew
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic