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

M

Michelle

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.
 
C

Christophe Vanfleteren

Michelle said:
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().
 
C

Christophe Vanfleteren

Michelle said:
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.
 
M

Matt Humphrey

Michelle said:
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 (e-mail address removed) http://www.iviz.com/
 

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

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top