Ejemplo n.º 1
0
 public void test_toOffsetDate_fixedOffset() {
   GregorianCalendar gcal = new GregorianCalendar(TimeZone.getTimeZone("GMT+12:00"));
   gcal.set(2008, 0, 1, 0, 0, 0);
   gcal.set(Calendar.MILLISECOND, 0);
   for (int i = 0; i < 500; i++) {
     OffsetDate test = gcal.toOffsetDate();
     assertEquals(test.getYear(), gcal.get(Calendar.YEAR));
     assertEquals(test.getMonthOfYear().getValue(), gcal.get(Calendar.MONTH) + 1);
     assertEquals(test.getDayOfMonth(), gcal.get(Calendar.DATE));
     assertEquals(test.getYear(), i < 366 ? 2008 : 2009);
     assertEquals(test.getOffset().getID(), "+12:00");
     gcal.add(Calendar.DATE, 1);
   }
 }
Ejemplo n.º 2
0
 public void test_toOffsetDate_variableOffset() {
   GregorianCalendar gcal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Paris"));
   gcal.set(2008, 0, 1, 0, 0, 0);
   gcal.set(Calendar.MILLISECOND, 0);
   for (int i = 0; i < 500; i++) {
     OffsetDate test = gcal.toOffsetDate();
     assertEquals(test.getYear(), gcal.get(Calendar.YEAR));
     assertEquals(test.getMonthOfYear().getValue(), gcal.get(Calendar.MONTH) + 1);
     assertEquals(test.getDayOfMonth(), gcal.get(Calendar.DATE));
     assertEquals(test.getYear(), i < 366 ? 2008 : 2009);
     boolean isDST = TimeZone.getTimeZone("Europe/Paris").inDaylightTime(gcal.getTime());
     assertEquals(test.getOffset().getID(), isDST ? "+02:00" : "+01:00");
     gcal.add(Calendar.DATE, 1);
   }
 }
Ejemplo n.º 3
0
 public void test_toOffsetDate_manualOffset() {
   GregorianCalendar gcal = new GregorianCalendar(TimeZone.getTimeZone("Europe/Paris"));
   gcal.set(2008, 0, 1, 0, 0, 0);
   gcal.set(Calendar.MILLISECOND, 0);
   gcal.set(Calendar.ZONE_OFFSET, 30 * 60 * 1000);
   gcal.set(Calendar.DST_OFFSET, 15 * 60 * 1000);
   for (int i = 0; i < 500; i++) {
     OffsetDate test = gcal.toOffsetDate();
     assertEquals(test.getYear(), gcal.get(Calendar.YEAR));
     assertEquals(test.getMonthOfYear().getValue(), gcal.get(Calendar.MONTH) + 1);
     assertEquals(test.getDayOfMonth(), gcal.get(Calendar.DATE));
     assertEquals(test.getYear(), i < 366 ? 2008 : 2009);
     assertEquals(test.getOffset().getID(), "+00:45");
     gcal.add(Calendar.DATE, 1);
     gcal.set(Calendar.ZONE_OFFSET, 30 * 60 * 1000);
     gcal.set(Calendar.DST_OFFSET, 15 * 60 * 1000);
   }
 }