I am trying to make an app where my app sending info with local time to the server, as my app will be used in a different country so I want to show the info send time with respect to local time. for example, if I send an info with local timeaug 19,2017 11.37 am from Bangladesh time to server, then the info will show in south America with the time aug 19,2017 0.36 am. my server is in America/Chicago.
I am trying with below code but not working:
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("America/Chicago"));
Date newDate= null;
try {
newDate = simpleDateFormat.parse("2017-08-19 11:15:21");
simpleDateFormat.setTimeZone(TimeZone.getDefault());
String desireDate=simpleDateFormat.format(newDate);
Log.v("TimeStamp",desireDate.toString());
} catch (ParseException e) {
e.printStackTrace();
}
I saw lots of similar problem in SO but no one working for me.