Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
sumanta panda
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use SimpleDateFormat.
 
Aditya Jha
Ranch Hand
Posts: 227
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic