List of usage examples for java.util Date UTC
@Deprecated public static long UTC(int year, int month, int date, int hrs, int min, int sec)
From source file:com.github.nmorel.gwtjackson.shared.AbstractTester.java
@SuppressWarnings("deprecation") public static long getUTCTime(int year, int month, int day, int hour, int minute, int second, int milli) { return Date.UTC(year - 1900, month - 1, day, hour, minute, second) + milli; }
From source file:com.tomtom.speedtools.json.JsonTest.java
@Test public void testToJsonRegularCases() throws ValidationFailException { LOG.info("testToJsonRegularCases"); ConstructorChecker.validateMethod(Json.class, "toJson", INT_JSON); final Integer i = 1; final String x0 = Json.toJson(i); LOG.info("Json Integer: " + x0); Assert.assertEquals(INT_JSON, x0);/*from w w w . jav a2 s . c o m*/ final GeoRectangle a = new GeoRectangle(new GeoPoint(1.0, 2.0), new GeoPoint(3.0, 4.0)); final String x1 = Json.toJson(a); LOG.info("Json GeoRectangle: " + x1); Assert.assertEquals(RECT_JSON, x1); final Uid<Integer> uid = new Uid<>("1-2-3-4-5"); final String x2 = Json.toJson(uid); LOG.info("Json Uid: " + x2); Assert.assertEquals("{\"uuid\":\"00000001-0002-0003-0004-000000000005\"}", x2); final Date d = new Date(Date.UTC(112, 4, 27, 11, 29, 10)); final String x3 = Json.toJson(d); LOG.info("Json Date: " + x3); Assert.assertEquals("\"2012-05-27T11:29:10.000+0000\"", x3); // TODO: UTCTime parsing errors final DateTime e = new DateTime(2012, 4, 27, 11, 29, 10, DateTimeZone.forTimeZone(TimeZone.getTimeZone("Europe/Amsterdam"))); final String x4 = Json.toJson(e); LOG.info("Json DateTime: " + x4); Assert.assertEquals("\"2012-04-27T11:29:10.000+0200\"", x4); }
From source file:com.tomtom.speedtools.json.JsonTest.java
@Test public void testFromJsonRegularCases() throws ValidationFailException { LOG.info("testFromJsonRegularCases"); ConstructorChecker.validateMethod(Json.class, "fromJson", INT_JSON, Integer.class); Json.fromJson(INT_JSON, Integer.class); LOG.info("Expecting 1 error now: 'Cannot map JSON...'"); final Integer i = Json.fromJson(RECT_JSON, Integer.class); Assert.assertNull(i);/*from www . ja va 2 s. c om*/ final Uid<Integer> uid = new Uid<>("1-2-3-4-5"); final String x1 = Json.toJson(uid); LOG.info("Json Uid: {}", x1); final Uid<?> x2 = Json.fromJson(x1, Uid.class); Assert.assertNotNull(x2); final String x3 = x2.toString(); Assert.assertEquals("00000001-0002-0003-0004-000000000005", x3); final Date w1 = new Date(Date.UTC(112, 1, 2, 3, 4, 5)); final String w2 = Json.toJson(w1); final Date w3 = Json.fromJson(w2, Date.class); Assert.assertNotNull(w3); LOG.info("Json Date: {} == {} / {}", w1, w3, w2); Assert.assertEquals(w1.getTime(), w3.getTime()); final DateTime v1 = new DateTime(2012, 1, 2, 3, 4, 5, 678); final String v2 = Json.toJson(v1); final DateTime v3 = Json.fromJson(v2, DateTime.class); Assert.assertNotNull(v3); LOG.info("Json DateTime: " + v1 + " == " + v3 + " / " + v2); Assert.assertEquals(v1.getMillis(), v3.getMillis()); final GeoPoint q = new GeoPoint(-1.0, -2.0); final String z1 = Json.toJson(q); LOG.info("Json GeoPoint 1: {}", z1); final GeoPoint r = Json.fromJson(z1, GeoPoint.class); Assert.assertNotNull(r); LOG.info("Json GeoPoint 2: {}", r); Assert.assertEquals(q, r); }