public void test_timeZoneFromString() throws Exception { Long nn = System.currentTimeMillis(); String tz = "Europe/Berlin"; DateTimeZone tzz = DateTimeZone.forID(tz); DateTime inberl = DateTimeOperations.convert(nn, DateTimeZone.forID(tz)); Assert.assertEquals(inberl, DateTimeOperations.convert(nn, tzz)); Assert.assertEquals("Europe/Berlin", tzz.getID()); Assert.assertEquals("Europe/Moscow", DateTimeZone.forID("Europe/Moscow").getID()); }
public void test_inLocale() throws Exception { Assert.assertEquals( "Heure d'Europe centrale", DateTimeZone.forID("Europe/Prague") .getName( DateTimeOperations.convert( new DateTime(2008, 1, 1, 12, 0, 0, 0, DateTimeZone.forID("Europe/Prague"))), Locale.FRENCH)); }
public void test_prague() throws Exception { DateTimeZone prg = DateTimeZone.forID("Europe/Prague"); Assert.assertEquals(prg, DateTimeZone.forID(prg.getID())); Assert.assertEquals("Europe/Prague", prg.getID()); Assert.assertEquals( "Central European Time", prg.getName(DateTimeOperations.convert(new DateTime(2008, 1, 1, 12, 0, 0, 0, prg)), null)); Assert.assertEquals( "CET", prg.getShortName( DateTimeOperations.convert(new DateTime(2008, 1, 1, 12, 0, 0, 0, prg)), null)); Assert.assertEquals( "Central European Summer Time", prg.getName(DateTimeOperations.convert(new DateTime(2008, 7, 1, 12, 0, 0, 0, prg)), null)); Assert.assertEquals( "CEST", prg.getShortName( DateTimeOperations.convert(new DateTime(2008, 7, 1, 12, 0, 0, 0, prg)), null)); }
public void test_zeroDateIsNotNever() throws Exception { Long at1January1970 = DateTimeOperations.convert(Period.seconds(0)); Assert.assertFalse( DateTimeOperations.compare( at1January1970, CompareType.EQ, null, DateTimeFieldType.millisOfSecond()) || DateTimeOperations.compare( at1January1970, CompareType.EQ, DateTimeOperations.never(), DateTimeFieldType.millisOfSecond())); }
public void test_london() throws Exception { DateTimeZone london = DateTimeZone.forID("Europe/London"); Assert.assertEquals(london, DateTimeZone.forID(london.getID())); Assert.assertEquals("Europe/London", london.getID()); Assert.assertEquals( "Greenwich Mean Time", london.getName( DateTimeOperations.convert(new DateTime(2008, 1, 1, 12, 0, 0, 0, london)), null)); Assert.assertEquals( "GMT", london.getShortName( DateTimeOperations.convert(new DateTime(2008, 1, 1, 12, 0, 0, 0, london)), null)); Assert.assertEquals( "British Summer Time", london.getName( DateTimeOperations.convert(new DateTime(2008, 7, 1, 12, 0, 0, 0, london)), null)); Assert.assertEquals( "BST", london.getShortName( DateTimeOperations.convert(new DateTime(2008, 7, 1, 12, 0, 0, 0, london)), null)); }
public void test_westernHemisphereTime() throws Exception { Long yesterday = DateTimeOperations.convert( (new DateTime(2009, 7, 23, 13, 18, 20, 0, DateTimeZone.forID("UTC")))); Assert.assertEquals( DateTimeOperations.print( yesterday, DateTimeFormat.shortTime(), null, DateTimeZone.forID("America/New_York")), DateTimeOperations.print( (DateTimeArithmetics.minus(yesterday, Period.hours(11))), DateTimeFormat.shortTime(), null, DateTimeZone.forID("Asia/Bangkok"))); }
public void test_westernHemisphereDate() throws Exception { Long yesterday = DateTimeOperations.convert( (new DateTime(2009, 7, 23, 13, 18, 20, 0, DateTimeZone.forID("UTC")))); Assert.assertFalse( (DateTimeOperations.print( yesterday, DateTimeFormat.fullDate(), Locale.US, DateTimeZone.forID("America/New_York"))) .equals( DateTimeOperations.print( (DateTimeArithmetics.plus(yesterday, Period.hours(22))), DateTimeFormat.fullDate(), Locale.US, DateTimeZone.forID("Asia/Bangkok")))); }
public void test_isNotNull2() throws Exception { DateTime dt = DateTimeOperations.convert(System.currentTimeMillis(), DateTimeZone.getDefault()); Assert.assertTrue(DateTimeOperations.isNotNull(dt)); Assert.assertFalse(DateTimeOperations.isNull(dt)); }