[threeten-dev] Localized GMT offset
Stephen Colebourne
scolebourne at joda.org
Fri Mar 22 16:47:28 PDT 2013
On 22 March 2013 23:35, Xueming Shen <xueming.shen at oracle.com> wrote:
> Maybe I did not describe it clearly, my apology. I meant, according to the
> CLDR, gmtFormat is the "localized format" for offset, with the default
> pattern for English as GMT {0}, in which the {0} should be replaced by
> the offset pattern. Which means in "localized" format, English included,
> the format for a offset is "GMT {0}" (or other prefix + offset}, but JSR310
> offset id is {0} only and the format defined is also the {0} part only.
> Personally I feel it is a little inconsistent. I think j.u.TZ has the
> GMT+hh:mm
> as well for the offset.
This is the difference between the value type (data) and the formatted output.
310:
ZoneOffset - an offset from GMT/UTC
ZoneId - a way of finding some rules
In both cases, the toString() method is simply outputting something
that is (a) appropriate and (b) fully defines the object.
JDK:
TimeZone - a way of finding some rules
Now, it just so happens that there is a TimeZone/ZoneId identifier
that consists of "GMT" followed by the offset. But that identifier
could also be "One hour behind Greenwich" - its just an identifier.
Completely separately, it maps onto a text format.
Because the text format and identifier are similar, it can get
confusing. But there is no inconsistency that I can see.
The "localized GMT offset" format is *only* concerned with ZoneOffset
printing in 310 terms, not ZoneId printing. Thus, these three
ZonedDateTime objects would print the same:
ZonedDateTime.of(2012, 6, 30, 12, 0, 0, 0, ZoneId.of("+01:00"));
ZonedDateTime.of(2012, 6, 30, 12, 0, 0, 0, ZoneId.of("GMT+01:00"));
ZonedDateTime.of(2012, 6, 30, 12, 0, 0, 0, ZoneId.of("UTC+01:00"));
all three would print "GMT+1" (short) or "GMT_01:00" (long) in English.
The ZoneId identifier is completely irrelevant.
> I agreed that we may just need a "appendLocalizedOffset(style)" for this
> and then just leave everything to the localized resource data from the
> installed data...
Yes, the only variable is SHORT vs LONG. Everything else is from the
locale data.
Stephen
More information about the threeten-dev
mailing list