I'm working on a project and i want to convert server time to local time using GMT. example my server is in Michigan in US and i'm living in Paris (France) and server time is 10:52 and i want to be converted to my local time 16:52 i use codes below and it does not seem to work. This convert time using GMT +12 instead of +6 and i don't know why help me please!!!!!!
public String GettingHeure(Context c, String date){
SimpleDateFormat datechanged = new SimpleDateFormat("HH:MM", Locale.getDefault());
Date dates = null;
String heureChanged = null;
try {
SimpleDateFormat formatter = new SimpleDateFormat("hh:mm",Locale.getDefault());
dates = formatter.parse(date);
TimeZone tz = TimeZone.getDefault();
formatter.setTimeZone(TimeZone.getTimeZone(tz.getID()));
System.out.println("local time : " + dates);
System.out.println("time in GMT : " + formatter.format(dates));
//Toast.makeText(c.getApplicationContext(), "String : "+ date+" "+formatter.format(dates), Toast.LENGTH_LONG).show();
heureChanged = formatter.format(dates);
SimpleDateFormat formatters = new SimpleDateFormat("hh:mm");
Date datess = formatters.parse(heureChanged);
System.out.println("local time : " + datess);
System.out.println("time in GMT : " + formatters.format(datess));
heureChanged = formatter.format(datess);
} catch (ParseException e) {
e.printStackTrace();
}
return heureChanged;