本文介紹了日期格式不起作用?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
String selectedDate = "2012-" + createdMonth + "-" + createdDay;
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
try {
createdDate = dateFormat.parse(selectedDate);
} catch (ParseException e1) {
e1.printStackTrace();
}
System.out.println(createdDate);
基本上當(dāng)我打印 createdDate 時,它??會顯示如下內(nèi)容:2012 年 3 月 8 日星期四 00:00:00 CST
Basically when I print createdDate, it will display something like this : Thu Mar 08 00:00:00 CST 2012
而不是這種格式的yyyy-MM-dd".非常感謝!
Instead of something of this format "yyyy-MM-dd". Thanks a bunch!
推薦答案
parse
方法返回一個 java.util.Date
,這就是 toString()
的 Date 實現(xiàn)返回.
The parse
method returns a java.util.Date
and that is the what the Date
implementation of toString()
returns.
這篇關(guān)于日期格式不起作用?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!