Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Newbie Question: How to return the current time in seconds or milliseconds?

Reply
Thread Tools

Newbie Question: How to return the current time in seconds or milliseconds?

 
 
Michelle
Guest
Posts: n/a
 
      08-16-2004
Hi,

May i know which class I should to return the current time in
seconds / milliseconds?

I have try using Date and Calendar class
but seems no method with similar functions.

thx.



 
Reply With Quote
 
 
 
 
Christophe Vanfleteren
Guest
Posts: n/a
 
      08-16-2004
Michelle wrote:

> Hi,
>
> May i know which class I should to return the current time in
> seconds / milliseconds?
>
> I have try using Date and Calendar class
> but seems no method with similar functions.
>
> thx.


Look at System.currentTimeMillis().

--
Kind regards,
Christophe Vanfleteren
 
Reply With Quote
 
 
 
 
Christophe Vanfleteren
Guest
Posts: n/a
 
      08-16-2004
Michelle wrote:

> Hi,
>
> May i know which class I should to return the current time in
> seconds / milliseconds?
>
> I have try using Date and Calendar class
> but seems no method with similar functions.
>
> thx.


Forgot to add, if you're a newbie, c.l.j.help is probably the better group
to ask your questions in the future.

--
Kind regards,
Christophe Vanfleteren
 
Reply With Quote
 
Matt Humphrey
Guest
Posts: n/a
 
      08-16-2004

"Michelle" <> wrote in message
news:cfqui2$2ct9$...
> Hi,
>
> May i know which class I should to return the current time in
> seconds / milliseconds?
>
> I have try using Date and Calendar class
> but seems no method with similar functions.


(new Date()).getTime () is the current time in milliseconds from Jan 1 1970
UTC. Alternative, use System.currentTimeMillis () which is also ms from
1/1/70.

Cheers,
Matt Humphrey http://www.iviz.com/


 
Reply With Quote
 
Michelle
Guest
Posts: n/a
 
      08-17-2004

"Matt Humphrey" <> wrote in message
news:F4-dnR1xuaq0Z73cRVn-...
>
> "Michelle" <> wrote in message
> news:cfqui2$2ct9$...
> > Hi,
> >
> > May i know which class I should to return the current time in
> > seconds / milliseconds?
> >
> > I have try using Date and Calendar class
> > but seems no method with similar functions.

>
> (new Date()).getTime () is the current time in milliseconds from Jan 1

1970
> UTC. Alternative, use System.currentTimeMillis () which is also ms from
> 1/1/70.
>
> Cheers,
> Matt Humphrey http://www.iviz.com/
>
>

Thanks.


 
Reply With Quote
 
Michelle
Guest
Posts: n/a
 
      08-17-2004

"Christophe Vanfleteren" <> wrote in message
news:qP6Uc.215839$...
> Michelle wrote:
>
> > Hi,
> >
> > May i know which class I should to return the current time in
> > seconds / milliseconds?
> >
> > I have try using Date and Calendar class
> > but seems no method with similar functions.
> >
> > thx.

>
> Forgot to add, if you're a newbie, c.l.j.help is probably the better group
> to ask your questions in the future.
>
> --
> Kind regards,
> Christophe Vanfleteren


Thanks.


 
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
How to convert Seconds to X Hours Y Minutes Z Seconds? 00_CP_D12 ASP .Net 3 02-22-2008 10:37 AM
convert seconds to hours:minutes:seconds `p Ruby 7 12-14-2005 03:32 PM
1. Ruby result: 101 seconds , 2. Java result:9.8 seconds, 3. Perl result:62 seconds Michael Tan Ruby 32 07-21-2005 03:23 PM
Convert seconds to minutes and seconds tshad ASP .Net 7 03-11-2005 11:27 PM
Converting seconds to (Days, Hours, Minutes, seconds) Stu C Programming 7 03-07-2005 08:44 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57