【问题标题】:How to change the timezone for my android application如何更改我的 android 应用程序的时区
【发布时间】:2014-03-20 06:25:58
【问题描述】:

我在我的应用程序中显示当前时间(设备时间)。我想更改时区,并希望在应用程序中显示更改时区的时间。

代码是这样的..

Calendar mCalendar; 
public CustomDate(Context context, AttributeSet attrs) {
    super(context, attrs);
    initClock(context);
 }

private void initClock(Context context) {

    if (mCalendar == null) {            
          mCalendar = Calendar.getInstance(); 
    }
    else
    {     
         mCalendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+04:00"));  
         mCalendar.setTimeZone(TimeZone.getTimeZone("Venezuela")); 
    }
    mFormatChangeObserver = new FormatChangeObserver();
    getContext().getContentResolver().registerContentObserver(
            Settings.System.CONTENT_URI, true, mFormatChangeObserver);   
}

我想在该 mCalendar 中返回更改后的时区时间。我没有得到值,同时显示。

【问题讨论】:

    标签: android timezone android-timepicker


    【解决方案1】:

    如果要更改系统默认时区,请使用AlarmManager的setTimeZone()

    【讨论】:

      猜你喜欢
      • 2012-01-25
      • 2023-04-02
      • 1970-01-01
      • 1970-01-01
      • 2016-05-19
      • 1970-01-01
      • 2016-07-09
      • 2012-12-12
      • 1970-01-01
      相关资源
      最近更新 更多