erictetz@gmail.com schrieb:
> My application is running an 'elapsed time' counter, which I would
> like to display in HH:MM:SS format. My question is how best to do this
[quoted text clipped - 10 lines]
>
> This outputs 16:00:00. I have no clue how to get rid of the 16.
See <http://java.sun.com/j2se/1.4.2/docs/api/java/util/Date.html#Date(long)>
The date Date(0) is specified as "January 1, 1970, 00:00:00 GMT", where
"GMT" means London time.
If you live somewhere in America (6 hours west of London), then this
time would be "December 31, 1969, 16:00:00" in your American time zone.
Hence the output would be correct.
> What am I doing wrong? Is there a cleaner approach for this?
Normally you won't use this Date(long) constructor, but instead some
other Date constructor or a Calendar method taking
year/month/day[/hour/minute] parameters. They all take your local
timezome into account, so that the problem should disappear.

Signature
Thomas
Lew - 14 Aug 2007 00:10 GMT
> "GMT" means London time.
Only in the winter time do they coincide. Actually it means "the mean solar
time at longitude 0°".
<http://en.wikipedia.org/wiki/Time_zone#Standard_time_zones>
<http://en.wikipedia.org/wiki/UT1>

Signature
Lew
Roedy Green - 22 Aug 2007 12:20 GMT
>> "GMT" means London time.
>
>Only in the winter time do they coincide. Actually it means "the mean solar
>time at longitude 0°".
When you mean standard time, say UTC which has no DST correction ever.
see http://mindprod.com/jgloss/timezone.html

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Thomas Fritsch - 14 Aug 2007 01:27 GMT
> The date Date(0) is specified as "January 1, 1970, 00:00:00 GMT", where
> "GMT" means London time.
> If you live somewhere in America (6 hours west of London), then this
Aaah, I meant "(8 hours west of London)"
because 16 + 8 = 24.
And yes, Lew is correct: I should say "(8 hours west of longitude 0°)"
> time would be "December 31, 1969, 16:00:00" in your American time zone.
> Hence the output would be correct.

Signature
Thomas
>My application is running an 'elapsed time' counter, which I would
>like to display in HH:MM:SS format. My question is how best to do this
>in Java. Note, I'm not using the latest version of Java which contains
>printf (which makes this trivial).
see http://mindprod.com/jgloss/calendar.html
The problem is you have to pick a timezone. The date itself is in
UTC.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com