This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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 Building Microservices this week in the Design 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: 14688

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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: date format problem
It's not a secret anymore!