Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > TimeFormat

Reply
Thread Tools

TimeFormat

 
 
Timo Nentwig
Guest
Posts: n/a
 
      02-27-2004
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
 
Reply With Quote
 
 
 
 
Collin VanDyck
Guest
Posts: n/a
 
      02-27-2004
"Timo Nentwig" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
 
Chris Smith
Guest
Posts: n/a
 
      02-27-2004
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
 
Reply With Quote
 
Jon A. Cruz
Guest
Posts: n/a
 
      02-27-2004
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)


 
Reply With Quote
 
Lee Fesperman
Guest
Posts: n/a
 
      02-28-2004
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)
 
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 change ASP's default timeformat? Crow ASP General 1 01-13-2004 03:25 PM



Advertisments