UTC时间转为正常日期

SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sf.setTimeZone(TimeZone.getTimeZone("UTC"));
Date date = null;
String dateTime = "";
String utcTime = "2018-08-07T01:00:59Z";
try {
date = sf.parse(utcTime);
dateTime = sdf.format(date);
System.out.println(dateTime);
} catch (ParseException e) {
e.printStackTrace();
}
posted @ 2019-04-11 15:02  雷神约  阅读(893)  评论(0编辑  收藏  举报