2020-03-13T14:45:00.000Z比正常时间少8小时
1.先将其转为2020-03-13 14:45:00的时间格式
maps.get("starttime")就是(2020-03-13T14:45:00.000Z格式的)
String timeStr = (String) maps.get("starttime"); SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'"); Date dateTime = SDF.parse(timeStr); SimpleDateFormat Time3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String starttime = Time3.format(dateTime);
2.在转化好的时间上加8小时即starttime为2020-03-13 22:45:00
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = null; try { date = format.parse(starttime); } catch (Exception ex) { ex.printStackTrace(); } Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.HOUR, 8);// 24小时制 date = cal.getTime(); cal = null; starttime = format.format(date); maps.put("starttime",starttime);