TimeFormat

Discussion in 'Java' started by Timo Nentwig, Feb 27, 2004.

  1. Timo Nentwig

    Timo Nentwig Guest

    Hi!

    Isn't there a TimeFormat just as there is a DecimalFormat?

    I want to do simple formating:

    long t0 = System.currentTimeMillis();
    ....
    long t1 = System.currentTimeMillis();

    time = new TimeFormat("mm:ss");
    time.format(t1-t0); // e.g. 5:17

    Regards
    Timo
    Timo Nentwig, Feb 27, 2004
    #1
    1. Advertising

  2. "Timo Nentwig" <> wrote in message
    news:eek:...
    > Hi!
    >
    > Isn't there a TimeFormat just as there is a DecimalFormat?
    >
    > I want to do simple formating:
    >
    > long t0 = System.currentTimeMillis();
    > ...
    > long t1 = System.currentTimeMillis();
    >
    > time = new TimeFormat("mm:ss");
    > time.format(t1-t0); // e.g. 5:17
    >
    > Regards
    > Timo


    You are looking for DateFormat (java.text.DateFormat).

    DateFormat df = DateFormat.getTimeInstance(DateFormat.SHORT);
    df.format(System.currentTimeInMillis());

    -CV
    Collin VanDyck, Feb 27, 2004
    #2
    1. Advertising

  3. Timo Nentwig

    Chris Smith Guest

    Timo Nentwig wrote:
    > Isn't there a TimeFormat just as there is a DecimalFormat?
    >
    > I want to do simple formating:
    >
    > long t0 = System.currentTimeMillis();
    > ...
    > long t1 = System.currentTimeMillis();
    >
    > time = new TimeFormat("mm:ss");
    > time.format(t1-t0); // e.g. 5:17


    I don't see anything for a time interval. For a time of day, use
    DateFormat or SimpleDateFormat.

    --
    www.designacourse.com
    The Easiest Way to Train Anyone... Anywhere.

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
    Chris Smith, Feb 27, 2004
    #3
  4. Timo Nentwig

    Jon A. Cruz Guest

    Timo Nentwig wrote:
    > Hi!
    >
    > Isn't there a TimeFormat just as there is a DecimalFormat?
    >
    > I want to do simple formating:
    >
    > long t0 = System.currentTimeMillis();
    > ...
    > long t1 = System.currentTimeMillis();
    >
    > time = new TimeFormat("mm:ss");
    > time.format(t1-t0); // e.g. 5:17



    See java.text.DateFormat and java.text.MessageFormat.

    (The latter should be used to put things together, instead of manually
    assembling string pieces)
    Jon A. Cruz, Feb 27, 2004
    #4
  5. Chris Smith wrote:
    >
    > Timo Nentwig wrote:
    > > Isn't there a TimeFormat just as there is a DecimalFormat?
    > >
    > > I want to do simple formating:
    > >
    > > long t0 = System.currentTimeMillis();
    > > ...
    > > long t1 = System.currentTimeMillis();
    > >
    > > time = new TimeFormat("mm:ss");
    > > time.format(t1-t0); // e.g. 5:17

    >
    > I don't see anything for a time interval. For a time of day, use
    > DateFormat or SimpleDateFormat.


    Nothing for time or date intervals. There is also no support in JDBC even though
    Interval is a SQL92 data type. Interval is the only SQL92 data type that JDBC ignores.

    --
    Lee Fesperman, FirstSQL, Inc. (http://www.firstsql.com)
    ==============================================================
    * The Ultimate DBMS is here!
    * FirstSQL/J Object/Relational DBMS (http://www.firstsql.com)
    Lee Fesperman, Feb 28, 2004
    #5
    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. Crow
    Replies:
    1
    Views:
    116
    Curt_C [MVP]
    Jan 13, 2004
Loading...

Share This Page