我从服务器获取UTC时间的时间戳并执行此操作:
public Calendar getSentOnInUTC() {
SimpleDateFormat sdf = new SimpleDateFormat(super.DATE_FORMAT, Locale.getDefault());
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
Calendar cal = Calendar.getInstance();
try {
cal.setTime(sdf.parse(this.sentOn));
} catch (ParseException e) {
UDebug.printExceptionStackTrace(e);
//*meh*
}
return cal;
}
现在,我想将返回日历内的时间转换为设备的本地时区。我怎么能这样做?