This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Java in General and the fly likes Date type conversion from dd/mm/yyyy to yyyy-mm-dd Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Date type conversion from dd/mm/yyyy to yyyy-mm-dd" Watch "Date type conversion from dd/mm/yyyy to yyyy-mm-dd" New topic
Author

Date type conversion from dd/mm/yyyy to yyyy-mm-dd

sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
Hello All,

my date is commming in dd/mm/yyyy.I want to convert to yyyy-mm-dd in java.

That is 12/06/2010 to 2010-06-12.

Please suggest.

Thanks,
SKP
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Use SimpleDateFormat.


[My Blog]
All roads lead to JavaRanch
Aditya Jha
Ranch Hand

Joined: Aug 25, 2003
Posts: 227

Or, if you're sure about the validity of source date, you can use a simple Regular Expression for conversion.

Using SimpleDateFormat lets you validate the input date. This is recommended if, say the source (input) date is a user input or read from a text file etc.
 
wood burning stoves
 
subject: Date type conversion from dd/mm/yyyy to yyyy-mm-dd