Android Daylight savings time设置问题

来源:互联网 发布:杭州软件行业排名 编辑:程序博客网 时间:2024/05/29 14:16
Android中对 Daylight savings time的处理是根据时区来处理的。
framework/com/android/server/AlarmManagerService.java有说明。


 TimeZone zone = TimeZone.getTimeZone(tz);
261        // Prevent reentrant calls from stepping on each other when writing
262        // the time zone property
263        boolean timeZoneWasChanged = false;
264        synchronized (this) {
265            String current = SystemProperties.get(TIMEZONE_PROPERTY);
266            if (current == null || !current.equals(zone.getID())) {
267                if (localLOGV) Slog.v(TAG, "timezone changed: " + current + ", new=" + zone.getID());
268                timeZoneWasChanged = true;
269                SystemProperties.set(TIMEZONE_PROPERTY, zone.getID());
270            }
271             
272            // Update the kernel timezone information
273            // Kernel tracks time offsets as 'minutes west of GMT'
274            int gmtOffset = zone.getRawOffset();
275            if (zone.inDaylightTime(new Date(System.currentTimeMillis()))) {
276                gmtOffset += zone.getDSTSavings();
277            }
278            setKernelTimezone(mDescriptor, -(gmtOffset / 60000));
279        }
280 
281        TimeZone.setDefault(null);
原创粉丝点击