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

Discussion in 'Java' started by Michelle, Aug 16, 2004.

  1. Michelle

    Michelle Guest

    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.
     
    Michelle, Aug 16, 2004
    #1
    1. Advertising

  2. 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
     
    Christophe Vanfleteren, Aug 16, 2004
    #2
    1. Advertising

  3. 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
     
    Christophe Vanfleteren, Aug 16, 2004
    #3
  4. "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/
     
    Matt Humphrey, Aug 16, 2004
    #4
  5. Michelle

    Michelle Guest

    "Matt Humphrey" <> wrote in message
    news:...
    >
    > "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.
     
    Michelle, Aug 17, 2004
    #5
  6. Michelle

    Michelle Guest

    "Christophe Vanfleteren" <> wrote in message
    news:qP6Uc.215839$-ops.be...
    > 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.
     
    Michelle, Aug 17, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joe, G.I.
    Replies:
    23
    Views:
    1,821
    Kai-Uwe Bux
    Oct 14, 2008
  2. Replies:
    3
    Views:
    2,011
    Steven D'Aprano
    Jul 25, 2009
  3. Michael Tan
    Replies:
    32
    Views:
    1,005
    Ara.T.Howard
    Jul 21, 2005
  4. Guy
    Replies:
    2
    Views:
    190
    Dr John Stockton
    Dec 5, 2003
  5. Ilya Zakharevich

    Converting milliseconds to seconds

    Ilya Zakharevich, Jan 11, 2008, in forum: Perl Misc
    Replies:
    31
    Views:
    594
    J├╝rgen Exner
    Feb 12, 2008
Loading...

Share This Page