https://blog.csdn.net/fang323619/article/details/74909587
***************************************************
/** * 传入Data类型日期,返回字符串类型时间(ISO8601标准时间) * @param date * @return */ public static String getISO8601Timestamp(Date date){ TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai"); //TimeZone tz = TimeZone.getTimeZone("GMT-01"); DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); df.setTimeZone(tz); String nowAsISO = df.format(date); return nowAsISO; }
时间输出的效果如:
2017-07-10T10:13:47.861Z