读书人

Calendar get local time zone

发布时间: 2012-08-31 12:55:03 作者: rapoo

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);
}

读书人网 >移动开发

热点推荐