• Post Reply Bookmark Topic Watch Topic
  • New Topic

converting string to date  RSS feed

 
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
Posts: 65833
134
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
Sheriff
Posts: 15862
81
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
Boost this thread!