转换带Tz的时间格式 public static String Time(String time) {try {String html="0秒"; String format; Object[] array; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");Date creationTime = sdf.parse(time);Calendar
public static String Time(String time) { try { String html="0秒"; String format; Object[] array; SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); Date creationTime = sdf.parse(time); Calendar cal = Calendar.getInstance(); cal.setTime(creationTime); cal.add(Calendar.HOUR, 8);//由于延迟8小时需要增加8小时时间 long transcodeTime = new Date().getTime() - cal.getTime().getTime(); long s = TimeUnit.MILLISECONDS.toSeconds(transcodeTime); Integer hours =(int) (s/(60*60)); Integer minutes = (int) (s/60-hours*60); Integer seconds = (int) (s-minutes*60-hours*60*60); if(hours>0){ format="已耗时"+"%1$,d时%2$,d分%3$,d秒"; array=new Object[]{hours,minutes,seconds}; }else if(minutes>0){ format="已耗时"+"%1$,d分%2$,d秒"; array=new Object[]{minutes,seconds}; }else{ format="已耗时"+"%1$,d秒"; array=new Object[]{seconds}; } html= String.format(format, array); return html; } catch (ParseException e) { e.printStackTrace(); return null; } }单纯的把时间转换成国际时间
final static String ALIYUN_DATE_TIME_PATTERN = "yyyy-MM-dd'T'HH:mm:ss'Z'"; DateUtil.formatTimeZone(new Date(), ALIYUN_DATE_TIME_PATTERN, "GMT+8", "GMT")