This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan 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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "date format problem" Watch "date format problem" New topic
Author

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);
try{
java.util.Date date2 = dateFormat.parse (dateStr);
}catch(ParseException pe){
pe.printStackTrace();}
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é
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

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: http://aspose.com/file-tools
 
subject: date format problem
 
Similar Threads
Date function
String GMT Date conversion to EST/EDT
Doubt in formatting date
How to get Yesterday's date
String to Date Conversion