aspose file tools*
The moose likes Beginning Java and the fly likes Java DateFormat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java DateFormat" Watch "Java DateFormat" New topic
Author

Java DateFormat

vikas Gourishetty
Ranch Hand

Joined: Aug 20, 2010
Posts: 38
Hi all,

I am trying to display the date and time.

I am using 'SimpleDateFormat' class.

---------------------------------------------------------------------------------------------------------------
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMM yyyy hh:mm");
String dateStr = simpleDateFormat.format(new Date());
System.out.println(+dateStr);
----------------------------------------------------------------------------------------------------------------

It is out putting: 16 Feb 2012 02:56.


Is there any way to display the date as: 16 Feb 2012 14:56

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

Yes. Read the javadoc for SimpleDateFormat again.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
vikas Gourishetty
Ranch Hand

Joined: Aug 20, 2010
Posts: 38
Bear Bibeault wrote:Yes. Read the javadoc for SimpleDateFormat again.


Thanks !!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

Did you find it?
vikas Gourishetty
Ranch Hand

Joined: Aug 20, 2010
Posts: 38
Bear Bibeault wrote:Did you find it?

Not yet bro.
vikas Gourishetty
Ranch Hand

Joined: Aug 20, 2010
Posts: 38
Bear Bibeault wrote:Did you find it?


I tried some string patterns:

"dd MMM yyyy hh:mm" !!

need to tweak this string !!
vikas Gourishetty
Ranch Hand

Joined: Aug 20, 2010
Posts: 38
vikas Gourishetty wrote:
Bear Bibeault wrote:Did you find it?


I tried some string patterns:

"dd MMM yyyy hh:mm" !!

need to tweak this string !!


well: here is the tweaked string ""dd MMM yyyy HH:mm"" ..!! gone blind for an hour!!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Java DateFormat