Fix parsing of HTTP Date years.

Change-Id: I17157eb145599e6e1a23c5ba77c3c713b8af14ff
This commit is contained in:
Ben Murdoch
2009-09-24 12:14:17 +01:00
parent 23703f16f8
commit d421995fdb

View File

@@ -184,11 +184,20 @@ public final class HttpDateTime {
} else {
return year + 2000;
}
} else
return (yearString.charAt(0) - '0') * 1000
} else if (yearString.length() == 3) {
// According to RFC 2822, three digit years should be added to 1900.
int year = (yearString.charAt(0) - '0') * 100
+ (yearString.charAt(1) - '0') * 10
+ (yearString.charAt(2) - '0');
return year + 1900;
} else if (yearString.length() == 4) {
return (yearString.charAt(0) - '0') * 1000
+ (yearString.charAt(1) - '0') * 100
+ (yearString.charAt(2) - '0') * 10
+ (yearString.charAt(3) - '0');
} else {
return 1970;
}
}
private static TimeOfDay getTime(String timeString) {