Skip to content

Commit

Permalink
Force English locale for date tests
Browse files Browse the repository at this point in the history
When using java.text.SimpleDateFormat without a locale, the system
default locale will be considered and if that is not set to an English
variant, the "EEE" part of the date string will be in a non-English
language. To overcome this, ensure that the English locale is used for
all tests where a java.util.Date is stringified.

Signed-off-by: Torbjörn SVENSSON <[email protected]>
  • Loading branch information
Torbjorn-Svensson authored and akurtakov committed Oct 1, 2023
1 parent ad0953a commit a12fe3e
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ public void run() {

@Test
public void test_headers_include() throws Exception {
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.ENGLISH);
format.setTimeZone(TimeZone.getTimeZone("GMT"));
final long date1 = System.currentTimeMillis() - (1000*60*60*24*365*30);
final long date2 = System.currentTimeMillis() - (1000*60*60*24*365*40);
Expand Down Expand Up @@ -1358,7 +1358,7 @@ protected void service(HttpServletRequest request, HttpServletResponse response)

@Test
public void test_headers_forward() throws Exception {
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.ENGLISH);
format.setTimeZone(TimeZone.getTimeZone("GMT"));
final long date1 = System.currentTimeMillis() - (1000*60*60*24*365*30);
final long date2 = System.currentTimeMillis() - (1000*60*60*24*365*40);
Expand Down

0 comments on commit a12fe3e

Please sign in to comment.