常用的时间字符串转换
生活随笔
收集整理的這篇文章主要介紹了
常用的时间字符串转换
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
String str="Thu Nov 08 22:55:02 CST 2018"; String str1="31/Aug/2016:00:00:01 +0800"; String str2="2018/9/10 12:00:11.000";SimpleDateFormat sdf = new SimpleDateFormat("dd/MMM/yyyy:HH:mm:ss",Locale.ENGLISH); SimpleDateFormat outsdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",Locale.ENGLISH); Date parse = sdf.parse(str1); String outStr = outsdf.format(parse); System.out.println(outStr);SimpleDateFormat sdf2 = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy",Locale.ENGLISH); Date parse1 = sdf2.parse(str); String outformat = outsdf.format(parse1); System.out.println(outformat);SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy/M/dd HH:mm:ss.SSS",Locale.ENGLISH); Date parse2 = sdf3.parse(str2); String outformat2 = outsdf.format(parse2); System.out.println(outformat2);轉載于:https://my.oschina.net/shea1992/blog/2873897
總結
以上是生活随笔為你收集整理的常用的时间字符串转换的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Redux 一个还好的redux 实践吧
- 下一篇: 地形图绘制过程中的自然斜坡、陡坎、斜坡的