Skip to content

Commit

Permalink
parse HTTP date correctly on JVM with non-EN default locale
Browse files Browse the repository at this point in the history
E.g. https://tools.ietf.org/html/rfc822#section-5 defines the valid
tokens for such dates and those have to be in EN-locale

eclipse-ee4j#622

Signed-off-by: Christian Nüssgens <[email protected]>
  • Loading branch information
nuessgens committed Jul 10, 2019
1 parent f6dfb47 commit 973565f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/src/main/java/org/glassfish/tyrus/core/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -452,15 +452,15 @@ public static int getWsPort(URI uri, String scheme) {
* @throws ParseException if the specified string cannot be parsed in neither of all three HTTP date formats.
*/
public static Date parseHttpDate(String stringValue) throws ParseException {
SimpleDateFormat formatRfc1123 = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");
SimpleDateFormat formatRfc1123 = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH);
try {
return formatRfc1123.parse(stringValue);
} catch (ParseException e) {
SimpleDateFormat formatRfc1036 = new SimpleDateFormat("EEE, dd-MMM-yy HH:mm:ss zzz");
SimpleDateFormat formatRfc1036 = new SimpleDateFormat("EEE, dd-MMM-yy HH:mm:ss zzz", Locale.ENGLISH);
try {
return formatRfc1036.parse(stringValue);
} catch (ParseException e1) {
SimpleDateFormat formatAnsiCAsc = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy");
SimpleDateFormat formatAnsiCAsc = new SimpleDateFormat("EEE MMM d HH:mm:ss yyyy", Locale.ENGLISH);
return formatAnsiCAsc.parse(stringValue);
}
}
Expand Down

0 comments on commit 973565f

Please sign in to comment.