public String utcToLocal1(String utcTime) { String datstr=""; try { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); df.setTimeZone(TimeZone.getTimeZone("UTC")); // SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String s = df.parse(utcTime).toString(); System.out.println(s); SimpleDateFormat sdf1 = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH); SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); datstr = sdf2.format(sdf1.parse(s)); System.out.println(datstr); }catch (Exception e){ e.printStackTrace(); } return datstr; }
java UTC->local
最新推荐文章于 2021-02-16 21:44:07 发布