This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes How o Display dateformat Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "How o Display dateformat" Watch "How o Display dateformat" New topic
Author

How o Display dateformat

anilellendula kumar
Ranch Hand

Joined: Jul 12, 2005
Posts: 43
Hai!

want date format like 22July2005-hh mm ss, can u help me on this
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8262

Have a look at java.text.DateFormat and java.text.SimpleDateFormat


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
anilellendula kumar
Ranch Hand

Joined: Jul 12, 2005
Posts: 43
hai!


Date date = new Date();
s3 = DateFormat.getDateInstance().format(date);


i tried this it is giving July 22, 2005 5:48:56 pm

i want 22 july 2005 "-" hh mm ss

which methods of DateFormat give this o/p
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

As Joe says, SimpleDateFormat does what you want. You will need to look very carefully at the Javadoc to make sure you setup the pattern you want.


Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
nan sud
Greenhorn

Joined: Feb 27, 2004
Posts: 8
example:

java.util.Date date = new java.util.Date();
java.text.SimpleDateFormat data = new java.text.SimpleDateFormat("EEE, MMM d,'-' HH:mm:ss z");
System. out.println(data.format(date).toString());
[ July 22, 2005: Message edited by: nan sud ]
yash Vi
Ranch Hand

Joined: Jul 17, 2005
Posts: 41
check these two links,

http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-dates.html

http://www.javaworld.com/javaworld/javaqa/2001-10/01-qa-1005-dateformat.html

It will help you do wot you want


Thanks for your reply and time.<br />Windows 2000,j2sdk1.4.2_08
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How o Display dateformat