TimeFormat

T

Timo Nentwig

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
 
C

Collin VanDyck

Timo Nentwig said:
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
 
C

Chris Smith

Timo said:
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
 
J

Jon A. Cruz

Timo said:
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)
 
L

Lee Fesperman

Chris said:
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.
 

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,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top