File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes date format problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "date format problem" Watch "date format problem" New topic

date format problem

rajareddy annavaarm
Ranch Hand

Joined: Mar 15, 2007
Posts: 96
I want to display dateformat like below
Mon 23 Apr 16:45 pm

I am using the following code'

DateFormat dateFormat = new SimpleDateFormat ("EEE MMM d hh:mm aaa");
java.util.Date date = new java.util.Date ();
String dateStr = dateFormat.format (date);
java.util.Date date2 = dateFormat.parse (dateStr);
}catch(ParseException pe){
I am getting output like Sat May 16 11:37:00 GMT+05:30 1970.

But I need output like Mon 23 Apr 16:45 pm.

How can I do that
Christophe Verré

Joined: Nov 24, 2005
Posts: 14687

Are you printing dateStr or date2 ?
Try this :

[My Blog]
All roads lead to JavaRanch
rajareddy annavaarm
Ranch Hand

Joined: Mar 15, 2007
Posts: 96
thanks Satou kurinosuke
its working
I agree. Here's the link:
subject: date format problem
Similar Threads
String to Date Conversion
Date function
Doubt in formatting date
String GMT Date conversion to EST/EDT
How to get Yesterday's date