File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "converting string to date" Watch "converting string to date" New topic
Author

converting string to date

pratik doshi
Greenhorn

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
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Hint: look in the java.text package.


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

Joined: Aug 16, 2005
Posts: 14074
    
  16

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 7 API documentation
Scala Notes - My blog about Scala
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: converting string to date
 
Similar Threads
first date and last date of month
Help:java.lang.String and java.sql.Date
How can I get sysdate in java?
JDBC SQL server date format problem
how to convert String into Date format