java中GMT時間格式轉換(其中一種方法)
阿新 • • 發佈:2019-01-04
//將GMT格式的時間轉換成yyyy-MM-dd HH:mm:ss格式 public String changeGmtTimeToDateTime(String GMTTime) { SimpleDateFormat sf = new SimpleDateFormat("EEE MMM dd yyyy hh:mm:ss z", Locale.ENGLISH); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = null; String dateTime = ""; try{ if (!Validator.isEmpty(GMTTime)) { date = sf.parse(GMTTime); dateTime = sdf.format(date); } } catch (ParseException e) { e.printStackTrace(); } return dateTime; }