Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

converting string to date

 
pratik doshi
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for eg:i have a string"02/11/2004"
i want to convert it to date in the same above format
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64843
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hint: look in the java.text package.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15284
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Date objects do not have a format. You can parse a String to a Date object using a SimpleDateFormat object, but the Date object itself doesn't have a format.

If you want to display the Date later, you just have to format it again (using a SimpleDateFormat object). You specify the format in the SimpleDateFormat object, not the Date object itself.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic