File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes converting string to date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "converting string to date" Watch "converting string to date" New topic

converting string to date

pratik doshi

Joined: Jul 22, 2010
Posts: 6
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

Joined: Jan 10, 2002
Posts: 63873

Hint: look in the java.text package.

[Asking smart questions] [About Bear] [Books by Bear]
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15100

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.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: converting string to date
It's not a secret anymore!