Java TimeZone.getTimeZone ("PDT") not working

It returns the default time zone for GMT.

Using SimpleTimeFormat with "z" for the time zone, it prints "PDT". But "PDT" is not in the list returned from TimeZone.getAvailableIDs (). Really weird!

Does anyone know why "PDT" is not a standard tz? How to deal with it? Someone calls my API passing in "PDT" as a time zone. Thank.

+3
source share
2 answers

PDT not a time zone

Does anyone know why "PDT" is not a standard TZ?

Because "PDT" is not a time zone!

'PDT' - - , , , (DST) (PST). 2-4 , , (!).

continent/region, America/Montreal, Africa/Casablanca Pacific/Auckland.

PDT :

ZoneId z = ZoneId.of( "America/Los_Angeles" ) ;
ZoneId z = ZoneId.of( "America/Tijuana" ) ;
ZoneId z = ZoneId.of( "America/Whitehorse" ) ;

PDT , (DST), D DST.

ZoneId z = ZoneId.of( "America/Phoenix" ) ;

SimpleTimeFormat, , java.time. DateTimeFormatter.

TimeZone. ZoneId.

ZoneId,

- API, "PDT" .

API, ZoneId, . .


java.time

java.time Java 8 . , java.util.Date, Calendar & SimpleDateFormat.

Joda-Time, , java.time.

, . Oracle. . : JSR 310.

java.time?

ThreeTen-Extra java.time . java.time. , Interval, YearWeek, YearQuarter more.

+7

"PDT" Pacific Daylight Time. Pacific Standard Time .

"America/Los_Angeles". .

wiki tz.

+4

All Articles