首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

Calendar get local time zone

2012-08-31 
Calendarget local time zone.Configuration userConfig new Configuration()Settings.System.getConfi

Calendar get local time zone.
Configuration userConfig = new Configuration();
Settings.System.getConfiguration( getContentResolver(), userConfig );
Calendar cal = Calendar.getInstance( userConfig.locale);
TimeZone tz = cal.getTimeZone();

when the user changes the time zone in the Settings app then the above will get the
newly updated value.

that wasn't obvious, wasn't it?


    /**
     * Calcuate if it's currently "daytime" by our internal definition. Used to
     * decide which icons to show when updating widgets.
     */
    public static boolean isDaytime() {
        Time time = new Time();
        time.setToNow();
        return (time.hour >= DAYTIME_BEGIN_HOUR && time.hour <= DAYTIME_END_HOUR);
    }

热点排行