Reputation: 1385
While I practicing JSTL timeZone tag, I tried to run these two actions:
<c:set var="now" value="<%= new java.util.Date() %>" />
<fmt:timeZone value="GMT+9:00">
<fmt:formatDate value="${now}" type="both"
dateStyle="full" timeStyle="full"/>
</fmt:timeZone>
<%-- and --%>
<fmt:timeZone value="KST">
<fmt:formatDate value="${now}" type="both"
dateStyle="full" timeStyle="full"/>
</fmt:timeZone>
I believe they should produce same result. However, they produce following two different time values.
2017년 8월 15일 화요일 오후(PM) 8시 03분 27초 GMT+09:00
2017년 8월 15일 화요일 오전(AM) 11시 03분 27초 GMT
Did I miss something or the implementation is incorrect? I case of mis-implementation, who should I contact?
Upvotes: 2
Views: 703
Reputation:
GMT+09:00
is not a timezone, it's a UTC offset: a difference (in hours, minutes and seconds) from UTC. It just means "9 hours ahead of UTC", and it's not attached to any specific region or country. (most systems, though, usually treats the offset as a "special type" of timezone, just to make things easier).
KST
is an abbreviation for Korea Standard Time, but is not a "true" timezone. Timezones names are not really standardized, but many systems use IANA timezones names (always in the format Region/City
, like Asia/Seoul
or Europe/London
).
The use of the short abbreviations (like CST
or KST
) is usually avoided by systems because they are ambiguous and not standard.
The timezone Asia/Seoul
uses KST
abbreviation today, but this was also used in the past by Asia/Pyongyang
. Though, they're not the same zone.
A timezone is a set of all different offsets that a region had, has and will have during its history. Today Asia/Seoul
uses the +09:00
offset, but Asia/Pyongyang
also used in the past, so their historical data are different (and that's why they are distinct zones).
Pyongyang had the +08:30
offset until 1912, when changed to +09:00
. But in 2015 it changed again to +08:30
and it's using it until today.
Seoul has a different offset history: it also used +08:30
in the past (in the 50's), with Daylight Saving Time (change to +09:30
during summer), then in 1961 it changed to +09:00
, had DST during some time, and today is using just +09:00
without DST.
All these changes are defined by governments and laws, and systems have no control over it. Just because a timezone (a region) uses some offset today, there's no guarantee that it'll use this forever.
So, although KST
can be a "synonym" of +09:00
today, it doesn't mean it'll be like that forever.
So, when you use GMT+09:00
, you're using just the offset, without any correlation to a specific timezone (because there are lots of timezones that can use this offset).
In the second case, it seems that the date is being converted from KST
(offfset +09:00
) to UTC (offset zero, or "GMT"). Note that the first case is 8 PM in offset +09:00
and the second is 11 AM in UTC (offset zero, or "GMT"), which is correct.
Maybe JSTL can't recognize KST
(because of its ambiguity) and uses UTC as a default. I'd try to replace it with Asia/Seoul
and see what happens.
Upvotes: 2
Reputation: 3002
It's not recommended to use three-letter time zone IDs. They are deprecated. And not all of them are supported.
See oracle java docs
Three-letter time zone IDs
For compatibility with JDK 1.1.x, some other three-letter time zone IDs (such as "PST", "CTT", "AST") are also supported. However, their use is deprecated because the same abbreviation is often used for multiple time zones (for example, "CST" could be U.S. "Central Standard Time" and "China Standard Time"), and the Java platform can then only recognize one of them.
Upvotes: 1