Skip to content

Commit

Permalink
Fixes issue #4174 - Fix issues related to HttpHeaderManager.getDateHe…
Browse files Browse the repository at this point in the history
…ader (#4175)
  • Loading branch information
Thihup authored Nov 8, 2024
1 parent 8a444a9 commit f12aeb9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public long getDateHeader(String name) throws IllegalArgumentException {
DefaultHttpHeader header = headers.get(name.toUpperCase(locale));
try {
String value = header.getValue();
SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");
SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", locale);
result = format.parse(value).getTime();
} catch (ParseException exception) {
throw new IllegalArgumentException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Enumeration;
import java.util.Locale;

import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;

Expand Down Expand Up @@ -82,7 +84,7 @@ void testContainsHeader() {
@Test
void testGetDateHeader() {
DefaultHttpHeaderManager manager = new DefaultHttpHeaderManager();
SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");
SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
manager.addHeader("NAME", format.format(new Date()));
assertTrue(manager.getDateHeader("NAME") > 0);
}
Expand Down

0 comments on commit f12aeb9

Please sign in to comment.