kumar Sudheer
kumar Sudheer

Reputation: 705

How to change the timezone for my android application

I am displaying the current time (device time) in my application. I would like to change the timezone and would like to display the time of changed timezone in the application.

and the code is like this..

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

I would like to return the changed timezone time in that mCalendar. I am not getting the value, same time is displaying.

Upvotes: 0

Views: 845

Answers (1)

MohK
MohK

Reputation: 1933

If you want to change system's default time zone, then use setTimeZone() of AlarmManager.

Upvotes: 1

Related Questions