日期轉化

public class TestDateTransform {
public static void main(String[] arg) throws ParseException{
String ti = “2017-10-10T17:33:03”;
SimpleDateFormat df = new SimpleDateFormat(“yyyy-MM-dd’T’hh:mm:ss”);
df.setTimeZone(TimeZone.getTimeZone(“GMT+8:00”));
SimpleDateFormat mdf = new SimpleDateFormat(“yyyy-MM-dd hh:mm:ss”);
System.out.println(mdf.format(df.parse(ti)));

}

public static void main1() throws ParseException{
    String ti = "2017-10-10T17:33:03+8:00";
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ssXXX");
    SimpleDateFormat mdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    System.out.println(mdf.format(df.parse(ti)));

}

}

發佈了101 篇原創文章 · 獲贊 7 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章