This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft 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 Java 8 in Action this week in the Java 8 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Date type conversion from dd/mm/yyyy to yyyy-mm-dd
 
Similar Threads
simpledateformat
Code review required for converting dateformat
date format conversion to MM/dd/yyyy hh:mm a
Unable to fetch records by using 'where' clause for a date type field in sql
How to fetch Date Field from excel sheet in Java