P.Hill wrote:
>> I said that System.currentTimeMillis() is *not* returning *local* time,
>> and you can only say it *does* if your current locale is *GMT*.
>
> Sorry, we are in agreement here. currentTimeMillis() returns GMT.
> I was not in any way trying to suggest, and don't see where I suggested,
> that currentTimeMillis() is possibly a local time at any place in this
> thread. If I did claim the currentTimeMillis() *might* return a local
> time then I'd have to make a statement about conversion to the
> internal format or claim that internally the value could be either
> local or GMT. Reading my post I think you'll agree I was assuming
> Date kept one consistent representation -- "GMT".
You said earlier "The value of [Date and currentTimeMillis()] are exactly
the same on a full size JDK.**The*Date constructor gets its time from
currentTimeMillis." This lead me to believe you were saying that both
currentTimeMillis() and the date representation were the same. If you were
talking about the internal representation of the date within the Date class
then your statement is either vague or misleading.
>> I also said
>> that the Date constructor takes the value returned by
>> System.currentTimeMillis() but does not return *that* as the local date
>> either, but instead uses other information to convert that value into the
>> local time when the local time is requested.
>
> But this is where the confusion starts. Constructors don't return
> anything.
And the confusion then is that I never said nor implied that they did.
> And in the case of java.util.Date() the constructor doesn't do
> any conversion. The result of a constructor is an object which interally
> has a GMT value. When the time is requested, there IS NO CONVERSION unless
> a readable string representation is requested then, and only then, is
> there a conversion.
That's what I was talking about. You put in one thing (a long value
representing the date in a singular way) and you get out of the black box
called Date a String that is your local date/time.
>> So they do the conversion internally. Where did I say otherwise?
>
> With your use of the word constructor in both your last message and
> in your penultimate message you suggest that on its way IN the value
> might be converted in some way.
The value is converted. But, the problem here is that you seem to think that
"conversion" means "changed". Perhaps a better term would be "translated"?
>> I said
>> before that Date "uses your timezone to convert [the value from
>> System.currentTimeMillis()] to the local time".
>
> Only the toString() method through the use of a SimpleDateFormat
> does any TZ aware conversion. Now in the ME edition it uses a slight
> different approach, but it still converts in the toString() method.
Translates. It seems we're in violent agreement on this topic.
>> Why are you on about the
>> deprecated constructors?
>
> I thought it would help to illustrate that Date does NOT store
> a timezone aware value. Apparently this was not a useful example.
> But to use them again as an example, if there is any conversion in the
> constructor as you stated,
I never stated that. The conversion/translation is in the *class*, with the
constructor collecting the value in this case.
> it would be in those deprecated ones.
That constructor is not deprecated in the MIDP.
> [ ... Date stores GMT millisecond value ... ]
>> Yeah, so? When did I say otherwise? I said that the value *RETURNED* by
>> Date was the local time.
>
> This is an imprecise statement.
It seems there's quite a bit of imprecision here. I was talking about the
toString() method. Yes, there are methods that will return the internal
representation of the date as you pointed out, but they're not the one
being discussed here.
> There are two methods that
> are not deprecated which return values and are not for comparison:
> getTime() and toString(). Do a myDate.getTime() and you get GMT
> milliseconds. Do a toString() and you get a string that is converted to
> the default TZ (not necessarily the local timezone), so 50% of the time
> you get a local time and 50% of the time you get GMT.
>
>> I never said it didn't hold the date internally as the
>> local date/time.
>
> Which I guess means you would say it does hold it in local time.
No. I'm saying that I *didn't* say anything about how the date is stored
internally. Try not to put words into my mouth.
> If you did state that internally it is local time
> you'd be making an incorrect statement. It is better to speak
> about what the class does internally, instead of talking about
> what the constructor does or what a particular method does.
> Internally the value in a Date object is GMT. Which is what
> I was trying to say.
I would say it's better to talk about what the public contract of the class
does and not about what happens internally, since such is subject to
potentially change.
>> I never said it didn't use the value, and *did* say explicitly that Date
>> *does* get its value from System.currentTimeMillis(). What's your point
>> in arguing with me?
>
> To point out a few mis-statements. I hope I have succeeded.
I think you've succeeded in pointing out some miscommunciations. You've
assumed more than I've stated.
>> You clarify something that wasn't in question. Nobody said that Date held
>> the local date/time...
>
> You just did above and in previous messages when you refered to
> constructors converting and I believe in your megation of what you claim
> you did say a few paragraphs above.
I said *nothing* about *what* is stored within the class. I said that it
(the default constructor for Date) *gets* the current timestamp *from*
System.currentTimeMillis() and also that the class *returns* a value that
is the local version of that value. I said nothing about what is stored
internally to the class; you're assuming that part.
> Just to summarize, I'll contain to try to point out that:
>
> 1. System.currentTimeMillis() always (to the abliity of the OS and
> hardware) returns a millisecond value since 1/1/1970 0:0:0 GMT.
I said this.
> 2. java.util.Date internally always uses GMT.
I said nothing about how Date stores the value, though it's safe to assume
this is probably the best practice.
> 3. java.util.Date.toString() uses the default TZ to create a localized
> string.
No problem here.
> 4. java.util.Date.getTime() returns a GMT value as stated in the
> documentation.
This only came up in this message from you.
> I hope everyone is on the same page now.
Yeah, but we've forgotten the point.
> But what of the original OP. Did he figure out his TZ problem?
That's been lost to antiquity...
--
/**
* @author Darryl L. Pierce <>
* @see The J2ME FAQ <http://mypage.org/mcpierce/j2mefaq.html>
* @quote "What do you care what others think, Mr. Feynman?"
* @geek echo '$_ = "Jvtu bopuifs Pfsm ibdlfs."; y/a-z/za-y/; print' |
perl
*/