獲取毫秒我有字符串格式的日期爲25 November 2010
,我試圖獲取該日期的毫秒,對於我做了下面的代碼:問題而從日期
strDateSelcted = "25 November 2010" // Actually i am receiving date in this format
SimpleDateFormat curFormater = new SimpleDateFormat("dd MMM yyyy");
try {
Date dateObj = curFormater.parse(strDateSelcted);
insertEventtoCalendar(dateObj.getTime()); // Actually insert an event onto the native calendar
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
但是,當我嘗試運行應用程序時,它會在插入日期的前一天創建一個事件,即對於2010年11月25日插入事件2010年11月24日和2010年11月27日插入事件2010年11月26日,並且相同。
所以,我犯了一個錯誤?請告訴我做的方式
我沒有得到你,你試圖從`2010年11月25日`獲取millis? – 2010-11-25 10:07:32
我不確定這是否對你有用,但我認爲在SimpleDateFormat中,MMM給出了這樣的月份:11月份和11月份沒有... – Sephy 2010-11-25 10:11:44
@ org.life.java你得到了,我想得到毫秒特殊日期(這裏,我有一個日期在字符串變量) – 2010-11-25 10:24:29