Code For Converting GMT To Device Time Zone Not Working
I have a time input in the following format from a RSS feed: Wed Jun 13 17:05:44 +0000 2012 and I need output as Wed Jun 13, 2012 22:35:44 The source time will be always in GMT, an
Solution 1:
First you required DateFormat to parse string value in Date object and then you can set Timezone in Date as well as you can make Calendar object with help of Date that calendar object will be your device timezone instance.
Below code is working at my side
String input_format = "EEE MMMMM dd HH:mm:ss Z yyyy";
String input_value="Wed Jun 13 17:05:44 +0000 2012";
Date date=null;
SimpleDateFormat sdf = new SimpleDateFormat(input_format);
try {
date = sdf.parse(input_value);
} catch (ParseException e) {
e.printStackTrace();
}
Calendar calendar = sdf.getCalendar();
calendar.setTime(date);
Solution 2:
if i understand it right, you just want to set the timezome
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.setTimeZone("Europe/Paris");
this for example set the timezone to Paris
Post a Comment for "Code For Converting GMT To Device Time Zone Not Working"