Beispiel #1
0
 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")));
 }
Beispiel #2
0
 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")));
 }
Beispiel #3
0
 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")));
 }
Beispiel #4
0
 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")));
 }
Beispiel #5
0
 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"))));
 }