Hmmm... Kevin...
versionUrl.openConnection().getLastModified()
"Returns the value of the last-modified header field. The result is the number of milliseconds since January 1, 1970 GMT."
So we get a long which accurately tells us the date (pretty ok-ish if you use .toHexString()). However, that new Date() thingy (and it's toString()) produces a date which is somewhat difficult to compare. Eg I get it in "CEST" - my local timezone.
Something like this would be better:
1 2 3 4 5
| import java.text.DateFormat; [...] DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,DateFormat.SHORT,Locale.ENGLISH); df.setTimeZone(TimeZone.getTimeZone("GMT")); System.out.println(df.format(new Date(versionUrl.openConnection().getLastModified()))); |
The locale was explictly set in order to get identical formatting.
Now I get:
Jul 11, 2004 10:56 PM
Instead of:
Mon Jul 12 00:56:48 CEST 2004 (and everyone would get something else here)
getLastModified() with toHexString and toUpperCase looks like this:
FDB06C3780 (also ok and comparable)
Anyways... great idea
