Android change timezone, time and date
I want开发者_C百科 to programtically set date, time and timezone in android. Is it possible. There are conflicting answers where some say is it possible and others say it is not possible.
It is posible. But you can start default system DateTimeSettingsSetupWizard.
int requestCode = 101; //any number
Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.setClassName("com.android.settings", "com.android.settings.DateTimeSettingsSetupWizard");
try {
startActivityForResult(intent, requestCode);
}
catch(ActivityNotFoundException e) {
Log.e(TAG, "startNewActivity - Not found Activity");
}
Surely the following class can do it? http://developer.android.com/reference/java/util/Date.html
LOCATION:
java.lang.Object ↳ java.util.Date
CONSTRUCTOR:
public Date (int year, int month, int day) Constructs a new Date initialized to midnight in the default TimeZone on the specified date. Parameters year the year, 0 is 1900. month the month, 0 - 11. day the day of the month, 1 - 31.
ALSO TRY USING:
As date class is deprecated in some instances, try using: GregorianCalendar(int, int, int)
精彩评论