wood burning stoves 2.0*
The moose likes Java in General and the fly likes how can i reformat a Date object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how can i reformat a Date object" Watch "how can i reformat a Date object" New topic
Author

how can i reformat a Date object

netanel weinberg
Greenhorn

Joined: May 10, 2004
Posts: 27
hello,
i have a date object with date details and i want to reformat it from yyyyy-MM-dd format to dd/MM/yyyy format how can i do it?

10x ahead,
netanel
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Moving this to the Intermediate forum...


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Ankur Srivastava
Ranch Hand

Joined: May 11, 2004
Posts: 62
You should use java.text.SimpleDateFormat class for your purpose.
Jack Kay
Ranch Hand

Joined: Aug 01, 2004
Posts: 62
Alright, import Date & DateFormat:


Now you'll create a Date & DateFormat object:


Now you'll format the Date with the DateFormatter:


The closest I could get you was to dd/MM/yy

I'll research around to find the answer!
[ August 01, 2004: Message edited by: Jack Kay ]
Jack Kay
Ranch Hand

Joined: Aug 01, 2004
Posts: 62
Ankur Srivastava was right.

[ August 01, 2004: Message edited by: Jack Kay ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how can i reformat a Date object
 
Similar Threads
Getting date as a string from util.date object in desired format format
How to determine Data Format while we are getting Data from Excel Sheet
Date Validation
Getting a Date from an string "mm/dd/yyyy'
how can i reformat a Date object