Android Daylight savings time設置問題

Android中對 Daylight savings time的處理是根據時區來處理的。


 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);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章