File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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
String to Date Conversion
Date function
Doubt in formatting date
String GMT Date conversion to EST/EDT
How to get Yesterday's date