我从jsonAPI" 2017-03-16T17:23:44.860Z"获得时间这样的字符串 我想要转换INDIAN STANDARD TIME ZONE格式如同这个3/16/2017 10:53:44 PM。 最后是textview.setText(" 3/16/2017 10:53:44 PM")
答案 0 :(得分:0)
首先,您可以将UTC转换为当前时区
String yourDate = "2017-03-16T17:23:44.860Z";
String inputFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'";
String outputFormat = "MM/dd/yyyy hh:mm:ss a";
SimpleDateFormat sdfInput = new SimpleDateFormat(inputFormat);
SimpleDateFormat sdfOutput = new SimpleDateFormat(outputFormat);
// Convert to local time zone
sdfOutput.setTimeZone(TimeZone.getDefault());
try {
Date parsed = sdfInput.parse(yourDate);
String outputDate = sdfOutput.format(parsed);
} catch (Exception e) {
Log.e("formattedDateFromString", "Exception in formateDateFromstring(): " + e.getMessage());
}