`

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);
    }
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics