aspose file tools
The moose likes Beginning Java and the fly likes Date Format Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Date Format" Watch "Date Format" New topic
Author

Date Format

Raj Mehta
Greenhorn

Joined: Apr 26, 2004
Posts: 11
How do I convert a String of the form "05272004" (MMDDYYYY) to a more meaningful format like 27th May, 2004.
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
Try reading java.text.DateFormat & see if you could work your answer out


SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
Raj Mehta
Greenhorn

Joined: Apr 26, 2004
Posts: 11
I had already taken a look at DateFormat class. And the only thing I thought would solve my problem was the Parse(String) method. But when I do this :

java.text.DateFormat df = java.text.DateFormat.getDateInstance();
df.parse("050272004");

I get the following error : Unparseable date: "06202004".

Any other suggestions ??
bart zagers
Ranch Hand

Joined: Feb 05, 2003
Posts: 234
In your approach, you did not (have) to specify the format of the string that you wanted to parse. It uses a default format that probably does not correspond to the one of your given string.

Did you notice that java.text.DateFormat is an abstract class?
Take a look at its subclass,
java.text.SimpleDateFormat,
which allows to specify a specific format.

Bart.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Date Format
 
Similar Threads
Help Needed in EL
Code for binary file to bitmap file conversion
Mock Exams for the new cert?
How to pass Arraylist values from an actionClass to a JSP page
Why is Refresh neccessary when loading the page?