我現在正在編寫一個服務器,我想檢查「If-Modified-Since:」標題。
既然有這麼多的日期的方法,這方法我應該考慮檢查一下,像通常的方法(毫秒在瀏覽器中使用的)....If-Modified-Since Date Format
Follwing是howi沒有爲毫秒格式。
Date date;
//dateS is a substring of If-Modified-Since: header
try{
long mills = Long.parseLong(dateS);
} catch (NumberFormatException e)
{e.printStackTrace();
}
date = new Date(mills);
我也想檢查 「星期三,2005年10月19日10:50:00 GMT」 格式。我怎樣才能把這個日期變成毫秒?
SimpleDateFormat dateFormat = new SimpleDateFormat(
"EEE, dd MMM yyyy HH:mm:ss z");
// to check if-modified-since time is in the above format
try {
ifModifiedSince = dateFormat.parse(date);
?????????????????????
} catch (ParseException e1) {
}
請幫我換款以上並請告訴我,如果有任何日期格式,我應該檢查..
已經回答了,我相信: [http://stackoverflow.com/questions/1930158/how-to-parse-date-from-http-last-modified-header][1] [1]:http://stackoverflow.com/questions/1930158/how-to-parse-date-from-http-last-modified-header – Farid
瀏覽器使用毫秒作爲Last-Modified-Date,因爲這是我的已在所有瀏覽器 – Ken
請求標題中我指的是使用format.parse(dateString).getTime(); – Farid