Here the that problem that i'm facing is -
First i have created a date object which will give me current date and time with device timezone i.e
Date date = new Date(); // Let say the time zone is India - GMT (+05:30)
The value of date is = "Mon Sep 24 13:54:06 GMT+05:30 2018"
No i have a Date formatter using which i have converted the following date object.
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss z");
sdf.setTimeZone(TimeZone.getTimeZone(loadPreferences(Utility.TIMEZONE_NAME)));
// Here the timezone is Hawaii (GMT-10:00)
Now getting the time as per the new time zone i.e., Hawaii
String dateS = sdf.format(date);
// This will give you the date with new timezone - "2018/09/23 22:24:06 GMT-10:00"
Now converting this string date to date object as -
Date newDate = sdf.parse(dateS);
Now the new date which i'm getting is not as per the timezone which i have passed.
The value of newDate which i'm getting is = "Mon Sep 24 13:54:06 GMT+05:30 2018"
//This is device timezone not the one i have set.
I have already tried "Z", "z", "X", "ZZ", "ZZZZZ" in the date formatter still no luck.
If any of you have any idea reading this then let me know.