Understanding the Etc/GMT time zone

2019-01-09 14:41发布

What is the rationale behind Apple using Etc/GMT timezone when they return the receipt from the App Store for auto-renewable subscriptions.

What exactly is the Etc/GMT time zone? Does the Java SDK understand this time zone? Or do I have to use other third-party libraries like Joda-Time?

2条回答
Bombasti
2楼-- · 2019-01-09 15:25

Etc/GMT is not strictly the same thing as UTC or GMT. They represent the same instant in time only when the offset is 0. In all other cases, they are quite different.

Apple explains the designation here.

A quote directly from the link gives an example:

We use POSIX-style signs in the Zone names and the output abbreviations, even though this is the opposite of what many people expect. POSIX has positive signs west of Greenwich, but many people expect positive signs east of Greenwich. For example, TZ='Etc/GMT+4' uses the abbreviation "GMT+4" and corresponds to 4 hours behind UTC (i.e. west of Greenwich) even though many people would expect it to mean 4 hours ahead of UTC (i.e. east of Greenwich).

查看更多
三岁会撩人
3楼-- · 2019-01-09 15:32

Etc/GMT is just a standard way of saying UTC, GMT, GMT0 or GMT+00:00.

The Java JDK understands all of the formats. You can easily see this in action by doing the following:

import java.util.TimeZone;

public class Playground {

    public static void main(String... args) {

        for (String s : TimeZone.getAvailableIDs()) {
            System.out.println(s);
        }
    }
}

This will print out all the different TimeZone formats that your Java JDK can parse:

...
Etc/GMT
Etc/GMT+0
Etc/GMT-0
Etc/GMT0
Etc/Greenwich
Etc/UCT
Etc/UTC
Etc/Universal
...

查看更多
登录 后发表回答