出处:/s/blog_7d8cef530101ersz.html
JAVA中将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;
}