How do I display the current time *including milliseconds*?

A

Al Koch

How do I display the current time *including milliseconds*?

Hello,

I need to display the current time including milliseconds. The following
code:

DateFormat dfDateTimeStartupThread =
DateFormat.getDateTimeInstance(DateFormat.FULL,DateFormat.FULL,Locale.getDef
ault());
String sDateTimeStartupThread = dfDateTimeStartupThread.format(new Date());
System.out.println(sDateTimeStartupThread);

results in output like:

June 25, 2005 1:23:18 PM EST

which is nicely formatteed but I cannot find any way to get the milliseconds
to display.

How can this be done?

Thanks,
Al Koch,
(e-mail address removed)
 
A

Al Koch

Hi Ray,
Take a look at java.util.SimpleDateFormat.

Thanks very much; that was exactly what I needed! (although it's actually
java.text.SimpleDateFormat).

Al,
(e-mail address removed)
 
R

Raymond DeCampo

Al said:
Hi Ray,




Thanks very much; that was exactly what I needed! (although it's actually
java.text.SimpleDateFormat).

Of course, I make that mistake every time...

Ray
 
J

Joly Makunga

Al said:
How do I display the current time *including milliseconds*?

Hello,

I need to display the current time including milliseconds. The following
code:

DateFormat dfDateTimeStartupThread =
DateFormat.getDateTimeInstance(DateFormat.FULL,DateFormat.FULL,Locale.getDef
ault());
String sDateTimeStartupThread = dfDateTimeStartupThread.format(new Date());
System.out.println(sDateTimeStartupThread);

results in output like:

June 25, 2005 1:23:18 PM EST

which is nicely formatteed but I cannot find any way to get the milliseconds
to display.

How can this be done?

Thanks,
Al Koch,
(e-mail address removed)
i do it like that

Date madate=new Date();

int heure=madate.getHours();
int minute=madate.getMinutes();
int jour=madate.getDate();

i don't know how to get millisecondes...

jolyqr
 
J

James Korman

i do it like that

Date madate=new Date();

int heure=madate.getHours();
int minute=madate.getMinutes();
int jour=madate.getDate();

i don't know how to get millisecondes...

jolyqr

Look at the JavaDoc for SimpleDateFormat, specifically the "S"
pattern character.

Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top