你的浏览器禁用了JavaScript, 请开启后刷新浏览器获得更好的体验!
输入关键字进行搜索
搜索:
没有找到相关结果
jiaxs - elasticsearch的忠实用户
赞同来自:
caobo
要回复问题请先登录或注册
3 个回复
jiaxs - elasticsearch的忠实用户
赞同来自:
caobo
赞同来自:
String utcTime = "2019-11-22T07:39:30.000Z";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String formatPattern = "yyyy-MM-dd HH:mm:ss";
ZonedDateTime zdt = ZonedDateTime.parse(utcTime);
LocalDateTime localDateTime = zdt.toLocalDateTime();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(formatPattern);
String gst = formatter.format(localDateTime.plusHours(8));
System.err.println(gst);
最后的输出结果是:
2019-11-22 15:39:30
caobo
赞同来自:
public static void main(String[] args) {
String utcTime = "2019-07-10T16:00:00.000Z";
String UTC = "2017-11-09T23:16:03.562Z";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
System.out.println(TimeZone.getTimeZone("UTC"));
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
Date UtcDate = null;
try {
UtcDate = sdf.parse(UTC);
} catch (Exception e) {
return;
}
System.out.println(UtcDate);
SimpleDateFormat localFormater = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(TimeZone.getDefault());
localFormater.setTimeZone(TimeZone.getDefault());
String localTime = localFormater.format(UtcDate.getTime());
System.out.println(localTime);
}