I use this Code
but not working properly in other time zone. How this time is changed by changing the time zone or current system time zone
int hour;
int minute;
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR, 16);
cal.set(Calendar.MINUTE, 30);
cal.set(Calendar.SECOND, 0);
cal.set(Calendar.AM_PM, Calendar.PM);
TimePicker asarTime=(TimePicker)findViewById(R.id.asarTime);
asarTime.setCurrentHour(16);
asarTime.setCurrentMinute(30);
Date currentLocalTime = cal.getTime();
SimpleDateFormat date = new SimpleDateFormat("HH:mm:ss z");
date.setTimeZone(TimeZone.getTimeZone("UTC"));
String localTime = date.format(currentLocalTime);
TextView timeShow=(TextView)findViewById(R.id.textView1);
timeShow.setText(currentLocalTime.toString());
First of all, set the timezone like this:
You could add a service that checks the timezone to update your application.
Actually it doesn’t happen too often, that an user has to change the timezone while using an application, so you can check this just everytime the application starts.