Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to parse system date to return Date and in yyyy-MM-dd format?

807606Feb 1 2007 — edited Feb 3 2007
DateFormat dateFormat = new SimpleDateFormat ("yyyy-MM-dd");
java.util.Date date = new java.util.Date ();
String dateStr = dateFormat.format (date);
try{
Date date2 = dateFormat.parse (dateStr);
}catch(ParseException pe){

pe.printStackTrace();
Actually, After parsing the date from string, again it is converted into dfault format i.e. 21 Jan 00.00.00 etc...

But I want this parsing date in yyyy-MM-dd format and again to return date.
Can anybody tell me how to do this?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 3 2007
Added on Feb 1 2007
13 comments
469 views