以编程方式更改android中的时区

问题描述:

我想以编程方式在android中更改时区,例如将时区设置为"America/Los_Angeles".我怎样才能做到这一点.通过使用ID怎么可能.

I wanted to change timezone in android programmatically like to set timezone as "America/Los_Angeles". How can I do this. How can this be possible by using id's.

在您的 AndroidManifest.xml

<uses-permission android:name="android.permission.SET_TIME_ZONE"/>

在您的来源中:

AlarmManager am = (AlarmManager) getContext().getSystemService(Context.ALARM_SERVICE);
am.setTimeZone("America/Los_Angeles");