utc毫秒值是个绝对值,和时区无关。如果需要转换为对应时区的时间表示,可以使用java.text.DateFormat的setTimeZone(timeZone)之后,进行format
如有疑问,请追问~
希望可以帮到你~ O(∩_∩)O谢谢~
UTC时间转换为本地时间的方法,其他的时区转换与此类似。
public static String utc2Local(String utcTime, String utcTimePatten,
String localTimePatten) {
SimpleDateFormat utcFormater = new SimpleDateFormat(utcTimePatten);
utcFormater.setTimeZone(TimeZone.getTimeZone("UTC"));
Date gpsUTCDate = null;
try {
gpsUTCDate = utcFormater.parse(utcTime);
} catch (ParseException e) {
e.printStackTrace();
}
SimpleDateFormat localFormater = new SimpleDateFormat(localTimePatten);
localFormater.setTimeZone(TimeZone.getDefault());
String localTime = localFormater.format(gpsUTCDate.getTime());
return localTime;
}