tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From radcor...@apache.org
Subject [tomee] 04/05: TOMEE-2428 - TimeZone issue
Date Thu, 03 Jan 2019 19:44:20 GMT
This is an automated email from the ASF dual-hosted git repository.

radcortez pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git

commit ff13509449922d3ad90dcfbc58f4901046a891b9
Author: Mariani Federico <federico.mariani.1990@gmail.com>
AuthorDate: Tue Jan 1 21:41:19 2019 +0100

    TOMEE-2428 - TimeZone issue
---
 .../src/main/java/org/superbiz/model/User.java               |  8 +++++++-
 .../src/test/java/org/superbiz/rest/UserServiceTest.java     | 12 ++++++++----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/examples/jsonb-configuration/src/main/java/org/superbiz/model/User.java b/examples/jsonb-configuration/src/main/java/org/superbiz/model/User.java
index 3626463..a7f93a9 100644
--- a/examples/jsonb-configuration/src/main/java/org/superbiz/model/User.java
+++ b/examples/jsonb-configuration/src/main/java/org/superbiz/model/User.java
@@ -1,17 +1,23 @@
 package org.superbiz.model;
 
+import java.util.Calendar;
 import java.util.Date;
+import java.util.TimeZone;
 
 public class User {
 
 	private Integer id;
 	private String name;
-	private Date registration = new Date(1234);
+	private Date registration;
 
 	public User(Integer id, String name) {
 		super();
 		this.id = id;
 		this.name = name;
+
+		final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+		c.set(2019, Calendar.JANUARY, 1);
+		registration = c.getTime();
 	}
 
 	/**
diff --git a/examples/jsonb-configuration/src/test/java/org/superbiz/rest/UserServiceTest.java
b/examples/jsonb-configuration/src/test/java/org/superbiz/rest/UserServiceTest.java
index e6f88cb..0bae71c 100644
--- a/examples/jsonb-configuration/src/test/java/org/superbiz/rest/UserServiceTest.java
+++ b/examples/jsonb-configuration/src/test/java/org/superbiz/rest/UserServiceTest.java
@@ -1,9 +1,10 @@
 package org.superbiz.rest;
 
 import java.io.IOException;
+import java.text.DateFormat;
 import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
+import java.util.Calendar;
+import java.util.TimeZone;
 
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.openejb.jee.WebApp;
@@ -32,9 +33,12 @@ public class UserServiceTest {
 		final String message = WebClient.create("http://localhost:4204").path("/test/api/users").get(String.class);
 		System.out.println(message);
 
-		final SimpleDateFormat sdf = new SimpleDateFormat("yyyy - MM - dd", Locale.ENGLISH);
+		final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+		c.set(2019, Calendar.JANUARY, 1);
+
+		DateFormat df = new SimpleDateFormat("yyyy - MM - dd");
+		String assertDate = df.format(c.getTime());
 
-		String assertDate = sdf.format(new Date(1234));
 		System.out.println(assertDate);
 		// test withDateFormat("yyyy - MM - dd")
 		Assert.assertTrue(message.contains(assertDate));


Mime
View raw message