I have a trouble on the timezone changer. I use the code
for (int i = 0; i < data.size(); i++) {
try {
String time = (String) data.get(i).get("time_utc_8");
time = time.replace('+', '-');
String pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSXXX";
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
TimeZone tz = TimeZone.getTimeZone("UTC+8");
sdf.setTimeZone(tz);
Date dateTime = sdf.parse(time);
String pattern_2 = "yyyy-MM-dd HH:mm:ss.SSSSSS";
SimpleDateFormat sdf_2 = new SimpleDateFormat(pattern_2);
String d = sdf_2.format(dateTime);
data.get(i).put("time_utc_8", d);
// System.out.println(data.get(i).get("time"));
} catch (JSONException e) {
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
to parse and change the timezone.
This is my example input:
2016-06-26T16:32:31.654120+00:00
And I get the output:
2016-06-27 00:43:25.000120
But the correct output must be:
2016-06-27 00:32:31.654120
How can I resolve the problem?