excel字符型轉(zhuǎn)換為日期型 如何將一個(gè)字符串轉(zhuǎn)換為時(shí)間格式?
如何將一個(gè)字符串轉(zhuǎn)換為時(shí)間格式?如果您想將日期輸出為2005年6月9日,我們可以這樣寫:simpledateformat SDF=new simpledateformat(“yyy-MM-DD”)st
如何將一個(gè)字符串轉(zhuǎn)換為時(shí)間格式?
如果您想將日期輸出為2005年6月9日,我們可以這樣寫:simpledateformat SDF=new simpledateformat(“yyy-MM-DD”)string str=sdf.format格式(parse(“2005-06-09 00:00:00”)str將以我們?cè)O(shè)置的格式輸出。使用的API是SimpleDataFormat,它屬于java.text.SimpleDataFormat所以請(qǐng)記住導(dǎo)入!用法:simpledateformat SDF=new simpledateformat(“yyy-MM-DD HH:MM:SS”)是最重要的一行,它建立了轉(zhuǎn)換的格式。Yyyy是一年中完整的一年,mm是月份,DD是日期。