SimpleDateFormat format = new SimpleDateFormat(" EEE, dd MMM yyyy HH:mm:ss zzz");
should work. It works here for me.
The extra space might have something to do with the way xml is formatted.
Question
I am trying to compare the date from the HTTP Last Modified header and to the requested file's last modified date.
I am using Tamper Data plugin in Firefox to add a Last-Modified header to test this and with the date: "Wed, 09 Apr 2008 23:55:38 GMT"
and for the file I am using file.lastModified()
.
I then convert file.lastModified into a Date object and then try to convert the request Last Modified date string into a Date but I get this error: java.text.ParseException: Unparseable date: " Wed, 09 Apr 2008 23:55:38 GMT"
Date fileDate = new Date(fileLm);
SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");
Date requestDate = format.parse(lmRequest);
System.out.println("this is filedate: " + fileDate);
System.out.println("this is requestdate: " + requestDate);
Be great if someone can help me. I can't figure out what's wrong :(
Solution
SimpleDateFormat format = new SimpleDateFormat(" EEE, dd MMM yyyy HH:mm:ss zzz");
should work. It works here for me.
The extra space might have something to do with the way xml is formatted.