commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hen...@apache.org
Subject [commons-jexl] branch master updated: JEXL: use UTC tz in SimpleDateFormat in test
Date Mon, 16 Dec 2019 08:10:48 GMT
This is an automated email from the ASF dual-hosted git repository.

henrib pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jexl.git


The following commit(s) were added to refs/heads/master by this push:
     new e4c8371  JEXL: use UTC tz in SimpleDateFormat in test
e4c8371 is described below

commit e4c8371cf2e43a7029f196ede37571a2c83bd15e
Author: henrib <henrib@apache.org>
AuthorDate: Mon Dec 16 09:08:13 2019 +0100

    JEXL: use UTC tz in SimpleDateFormat in test
---
 .../java/org/apache/commons/jexl3/ArithmeticOperatorTest.java  | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/test/java/org/apache/commons/jexl3/ArithmeticOperatorTest.java b/src/test/java/org/apache/commons/jexl3/ArithmeticOperatorTest.java
index fb44e76..f14853f 100644
--- a/src/test/java/org/apache/commons/jexl3/ArithmeticOperatorTest.java
+++ b/src/test/java/org/apache/commons/jexl3/ArithmeticOperatorTest.java
@@ -44,6 +44,7 @@ import org.junit.Test;
  */
 @SuppressWarnings({"UnnecessaryBoxing", "AssertEqualsBetweenInconvertibleTypes"})
 public class ArithmeticOperatorTest extends JexlTestCase {
+    private static final TimeZone UTC = TimeZone.getTimeZone("UTC");
     private Asserter asserter;
 
     @Before
@@ -354,7 +355,7 @@ public class ArithmeticOperatorTest extends JexlTestCase {
 
         protected Object getDateValue(Date date, String key) {
             try {
-                Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+                Calendar cal = Calendar.getInstance(UTC);
                 cal.setTime(date);
                 if ("yyyy".equals(key)) {
                     return cal.get(Calendar.YEAR);
@@ -373,7 +374,7 @@ public class ArithmeticOperatorTest extends JexlTestCase {
         }
 
         protected Object setDateValue(Date date, String key, Object value) throws Exception
{
-            Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+            Calendar cal = Calendar.getInstance(UTC);
             cal.setTime(date);
             if ("yyyy".equals(key)) {
                 cal.set(Calendar.YEAR, toInteger(value));
@@ -420,6 +421,7 @@ public class ArithmeticOperatorTest extends JexlTestCase {
 
         public String format(Date date, String fmt) {
             SimpleDateFormat sdf = new SimpleDateFormat(fmt, locale);
+            sdf.setTimeZone(UTC);
             return sdf.format(date);
         }
 
@@ -473,7 +475,7 @@ public class ArithmeticOperatorTest extends JexlTestCase {
 
     @Test
     public void testFormatArithmetic() throws Exception {
-        Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+        Calendar cal = Calendar.getInstance(UTC);
         cal.set(1969, 7, 20);
         Date x0 = cal.getTime();
         String y0 =  "MM/yy/dd";
@@ -519,7 +521,7 @@ public class ArithmeticOperatorTest extends JexlTestCase {
     public void testFormatArithmeticJxlt() throws Exception {
         Map<String, Object> ns = new HashMap<String, Object>();
         ns.put("calc", Aggregate.class);
-        Calendar cal = Calendar.getInstance();
+        Calendar cal = Calendar.getInstance(UTC);
         cal.set(1969, 7, 20);
         Date x0 = cal.getTime();
         String y0 =  "yyyy-MM-dd";


Mime
View raw message