public static final SimpleDateFormat DATE_TIME_ZONE = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
/**
* 得到格林时间 格式:2020-02-25T16:00:00.00Z
* @param s
* @return
*/
public static String timeTZ(long s) {
String time1 = DateUtils.date2String(s, "yyyy-MM-dd HH:mm:ss");
Date time = null;
String result = null;
try {
time = DEFAULT_DATE_FORMAT.parse(time1);
result = DATE_TIME_ZONE.format(time);
} catch (ParseException e) {
e.printStackTrace();
}
return result.replace("+0800", "Z");
}

本文介绍了一种使用Java将长整型时间戳转换为特定格林威治时间格式的方法,包括使用SimpleDateFormat类进行日期格式化的过程。
1万+

被折叠的 条评论
为什么被折叠?



