maxhuang
maxhuang

Reputation: 2961

Why is the short display name for Asia/Manila timezone PT in java?

jshell> import java.time.*;

jshell> import java.time.format.*;

jshell> ZoneId.of("Asia/Manila").getDisplayName(TextStyle.SHORT, Locale.getDefault())
$1 ==> "PT"

From wikipedia: Philippine Standard Time (PST or PhST), also known as Philippine Time (PHT), is the official name for the time zone used in the Philippines.

https://en.wikipedia.org/wiki/Philippine_Standard_Time

Shouldn't it be PST instead of PT?

Upvotes: 0

Views: 1190

Answers (2)

Andy Turner
Andy Turner

Reputation: 140318

The reason is that it doesn't know the instant at which you want to know the time zone name. Exactly the same thing happens for America/Los_Angeles:

jshell> ZoneId.of("America/Los_Angeles").getDisplayName(TextStyle.SHORT, Locale.getDefault())
$4 ==> "PT"

Try formatting an ZonedDateTime to just include the short zone name, you'll find it uses PST or PDT for Philippines Standard Time and Philippines Daylight Time respectively.

jshell> DateTimeFormatter.ofPattern("z").format(ZonedDateTime.now(ZoneId.of("Asia/Manila")))
$8 ==> "PST"

As to why it does this: depends on which version of Java you are using, but it is because something like this code is used to specify timezone names:

            {"Asia/Manila", new String[] {"Philippines Standard Time", "PST",
                                          "Philippines Daylight Time", "PDT",
                                          "Philippines Time", "PT"}},

It's not just the Philippines that has a non-standard "default" name: amongst many others, as a Brit, I have never heard the term "British Time" before, or seen the abbreviation "BT" used in this way.

        String GMTBST[] = new String[] {"Greenwich Mean Time", "GMT",
                                        "British Summer Time", "BST",
                                        "British Time", "BT"};
jshell> ZoneId.of("Europe/London").getDisplayName(TextStyle.SHORT, Locale.getDefault())
$10 ==> "BT"

Upvotes: 3

SikorskyS60
SikorskyS60

Reputation: 180

PST is the abbrevation for the Pacific Standart Time, so that's taken. It's like you've written in your question, PHT is the normal abbrevation for the Philippine Standart Time.

As for the "why PT":

That's just what they choose for Java.

Upvotes: 0

Related Questions