Exemplo n.º 1
0
 public void test_toLocalDateTime_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++) {
     LocalDateTime test = gcal.toLocalDateTime();
     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.toLocalTime().toNanoOfDay(), 0);
     assertEquals(test.getYear(), i < 366 ? 2008 : 2009);
     gcal.add(Calendar.DATE, 1);
   }
 }
Exemplo n.º 2
0
 public void test_toLocalDateTime_endOfDay() {
   GregorianCalendar gcal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
   gcal.set(2008, 0, 1, 23, 59, 59);
   gcal.set(Calendar.MILLISECOND, 0);
   for (int i = 0; i < 500; i++) {
     LocalDateTime test = gcal.toLocalDateTime();
     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.toLocalTime().toNanoOfDay(), (24L * 60L * 60L - 1L) * 1000000000L);
     assertEquals(test.getYear(), i < 366 ? 2008 : 2009);
     gcal.add(Calendar.DATE, 1);
   }
 }