简体   繁体   中英

java: Calendar.HOUR_OF_DAY returns incorrect value. Why?

The java code below:

Calendar calend = Calendar.getInstance(TimeZone
                .getTimeZone("Pacific/Fakaofo"));

        System.out.println(calend.get(Calendar.HOUR_OF_DAY) + ":"
                + calend.get(Calendar.MINUTE) + ":" + calend.get(Calendar.SECOND));

Actual result : 2:21:19

Expected result : 1:21:19 ( http://www.timeanddate.com/worldclock/city.html?n=738 ).

Why does actual result contain one extra hour?

According to Pacific/Fakaofo Time Zone it is

Wed 20-Mar-2013 02:31 A.M.

so your actual result seems correct.

Tokelau: Wrong local time for over 100 years might be the answer. There seems to be some confusion about the real timezone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM