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 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
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: 14688
    
  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.
 
Consider Paul's rocket mass heater.
 
subject: Date type conversion from dd/mm/yyyy to yyyy-mm-dd