Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How do I display the current time *including milliseconds*?

Reply
Thread Tools

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

 
 
Al Koch
Guest
Posts: n/a
 
      06-25-2005

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,Dat eFormat.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,
http://www.velocityreviews.com/forums/(E-Mail Removed)





 
Reply With Quote
 
 
 
 
Raymond DeCampo
Guest
Posts: n/a
 
      06-25-2005
Al Koch wrote:
> How do I display the current time *including milliseconds*?
>


Take a look at java.util.SimpleDateFormat.

HTH,
Ray

--
XML is the programmer's duct tape.
 
Reply With Quote
 
 
 
 
Al Koch
Guest
Posts: n/a
 
      06-27-2005
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 Removed)


 
Reply With Quote
 
Raymond DeCampo
Guest
Posts: n/a
 
      06-27-2005
Al Koch wrote:
> 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).
>


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

Ray

--
XML is the programmer's duct tape.
 
Reply With Quote
 
Joly Makunga
Guest
Posts: n/a
 
      06-30-2005
Al Koch wrote:

> 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,Dat eFormat.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 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
 
Reply With Quote
 
James Korman
Guest
Posts: n/a
 
      07-02-2005
On Thu, 30 Jun 2005 11:40:47 +0200, Joly Makunga
<(E-Mail Removed)> wrote:

>Al Koch wrote:
>
>> 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,Dat eFormat.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 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


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

Jim
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JAVA Time Problem: Want to get the current time and perform validation The One Java 5 11-29-2006 02:37 PM
Is time.time() < time.time() always true? flamesrock Python 8 11-24-2006 06:51 AM
Display current time JCO Javascript 7 02-12-2004 06:30 AM
Formatting a time (not current time) B. Schad Java 8 09-04-2003 07:39 AM
How to change the current thread current culture at run time. Manu ASP .Net 1 07-20-2003 03:27 PM



Advertisments