public void test_nowIsNotNever() throws Exception { Long nowDate = System.currentTimeMillis(); Assert.assertTrue( DateTimeOperations.compare( nowDate, CompareType.NE, DateTimeOperations.never(), DateTimeFieldType.millisOfSecond())); }
public void test_nullIsNever() throws Exception { Long nullDate = null; Assert.assertTrue( DateTimeOperations.compare( nullDate, CompareType.EQ, DateTimeOperations.never(), DateTimeFieldType.millisOfSecond())); }
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_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_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_timeZoneFromStringLiteral() throws Exception { Long thisMoment = System.currentTimeMillis(); Assert.assertEquals( DateTimeOperations.print( thisMoment, (MainFormatTable.INSTANCE).getFormatter("date/time"), null, DateTimeZone.forID("Europe/Moscow")), DateTimeOperations.print( thisMoment, (MainFormatTable.INSTANCE).getFormatter("date/time"), null, DateTimeZone.forID("Europe/Moscow"))); }
public void test_londonAndMoscowShortTime() throws Exception { Long current = System.currentTimeMillis(); Assert.assertEquals( DateTimeOperations.print( current, DateTimeFormat.shortTime(), new Locale("ru", "RU", ""), DateTimeZone.forID("Europe/London")), DateTimeOperations.print( (DateTimeArithmetics.minus(current, Period.hours(3))), DateTimeFormat.shortTime(), new Locale("ru", "RU", ""), DateTimeZone.forID("Europe/Moscow"))); }
public void test_timeZoneFromVariable() throws Exception { String zone = "Europe/Berlin"; Long thisMoment = System.currentTimeMillis(); Assert.assertEquals( DateTimeOperations.print( thisMoment, (MainFormatTable.INSTANCE).getFormatter("date/time"), null, DateTimeZone.forID(zone)), DateTimeOperations.print( thisMoment, (MainFormatTable.INSTANCE).getFormatter("date/time"), null, DateTimeZone.forID("Europe/Berlin"))); }
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_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_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_isNull2() throws Exception { DateTime dt = null; Assert.assertTrue(DateTimeOperations.isNull(dt)); Assert.assertFalse(DateTimeOperations.isNotNull(dt)); }
public void test_isNotNull2() throws Exception { DateTime dt = DateTimeOperations.convert(System.currentTimeMillis(), DateTimeZone.getDefault()); Assert.assertTrue(DateTimeOperations.isNotNull(dt)); Assert.assertFalse(DateTimeOperations.isNull(dt)); }
public void test_isNotNull() throws Exception { Long dt = null; Assert.assertFalse(DateTimeOperations.isNotNull(dt)); Assert.assertTrue(DateTimeOperations.isNotNull(System.currentTimeMillis())); }
public void test_nullCompareEquals() throws Exception { Long dt1 = null; Long d2 = null; Assert.assertTrue( DateTimeOperations.compare(dt1, CompareType.EQ, d2, DateTimeFieldType.millisOfSecond())); }
public void test_nullCompareNotEquals() throws Exception { Long dt1 = null; Long dt2 = System.currentTimeMillis(); Assert.assertTrue( DateTimeOperations.compare(dt1, CompareType.NE, dt2, DateTimeFieldType.millisOfSecond())); }
public void test_nullLess() throws Exception { Long dt1 = System.currentTimeMillis(); Long d2 = null; Assert.assertTrue( DateTimeOperations.compare(dt1, CompareType.GT, d2, DateTimeFieldType.millisOfSecond())); }