Search in sources :

Example 71 with GregorianCalendar

use of java.util.GregorianCalendar in project j2objc by google.

the class CalendarTest method testAddTwoDaysOver30MinuteDstForwardAdds47AndAHalfHours.

public void testAddTwoDaysOver30MinuteDstForwardAdds47AndAHalfHours() {
    Calendar calendar = new GregorianCalendar(AUSTRALIA_LORD_HOWE);
    // 02:10 GMT+10:30
    calendar.set(2011, 9, 1, 2, 10);
    double hoursSinceEpoch = hoursSinceEpoch(calendar);
    calendar.add(Calendar.DATE, 2);
    assertEquals(47.5, hoursSinceEpoch(calendar) - hoursSinceEpoch);
    // 02:10 GMT+11:00; +47.5 hours
    assertCalendarEquals(calendar, 2011, 9, 3, 2, 10);
}
Also used : Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar)

Example 72 with GregorianCalendar

use of java.util.GregorianCalendar in project j2objc by google.

the class CalendarTest method testAddOneDayOverDstForwardAdds24HoursAt0000.

/**
     * At their daylight savings time switch, Sao Paulo changes from
     * "00:00 GMT-3" to "01:00 GMT-2". When adding time across this boundary,
     * drop an hour to keep the hour+minute constant unless that prevents the
     * date field from being incremented.
     * http://code.google.com/p/android/issues/detail?id=17502
     */
public void testAddOneDayOverDstForwardAdds24HoursAt0000() {
    Calendar calendar = new GregorianCalendar(AMERICA_SAO_PAULO);
    // 00:00 GMT-3
    calendar.set(2011, 9, 15, 0, 0);
    double hoursSinceEpoch = hoursSinceEpoch(calendar);
    calendar.add(Calendar.DATE, 1);
    assertEquals(24.0, hoursSinceEpoch(calendar) - hoursSinceEpoch);
    // 01:00 GMT-2; +24 hours
    assertCalendarEquals(calendar, 2011, 9, 16, 1, 0);
}
Also used : Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar)

Example 73 with GregorianCalendar

use of java.util.GregorianCalendar in project j2objc by google.

the class CalendarTest method testAddOneDayOverDstForwardAdds23HoursAt0100.

public void testAddOneDayOverDstForwardAdds23HoursAt0100() {
    Calendar calendar = new GregorianCalendar(AMERICA_SAO_PAULO);
    // 01:00 GMT-3
    calendar.set(2011, 9, 15, 1, 0);
    double hoursSinceEpoch = hoursSinceEpoch(calendar);
    calendar.add(Calendar.DATE, 1);
    assertEquals(23.0, hoursSinceEpoch(calendar) - hoursSinceEpoch);
    // 01:00 GMT-2; +23 hours
    assertCalendarEquals(calendar, 2011, 9, 16, 1, 0);
}
Also used : Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar)

Example 74 with GregorianCalendar

use of java.util.GregorianCalendar in project j2objc by google.

the class CalendarTest method test_clear_45877_morning.

// https://code.google.com/p/android/issues/detail?id=45877
public void test_clear_45877_morning() {
    GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("America/Los_Angeles"));
    // 3rd February 2016 05:32:40.000 America/Los_Angeles time.
    cal.setTimeInMillis(1454506360000L);
    checkClear(cal, 0, 28800000);
}
Also used : GregorianCalendar(java.util.GregorianCalendar)

Example 75 with GregorianCalendar

use of java.util.GregorianCalendar in project j2objc by google.

the class CalendarTest method testAdd24HoursOverDstForwardAdds24Hours.

public void testAdd24HoursOverDstForwardAdds24Hours() {
    Calendar calendar = new GregorianCalendar(AMERICA_SAO_PAULO);
    // 01:00 GMT-3
    calendar.set(2011, 9, 15, 1, 0);
    double hoursSinceEpoch = hoursSinceEpoch(calendar);
    calendar.add(Calendar.HOUR, 24);
    assertEquals(24.0, hoursSinceEpoch(calendar) - hoursSinceEpoch);
    // 02:00 GMT-2; +24 hours
    assertCalendarEquals(calendar, 2011, 9, 16, 2, 0);
}
Also used : Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar)

Aggregations

GregorianCalendar (java.util.GregorianCalendar)1278 Calendar (java.util.Calendar)603 Date (java.util.Date)377 Test (org.junit.Test)247 SimpleDateFormat (java.text.SimpleDateFormat)104 Timestamp (java.sql.Timestamp)54 ScheduleExpression (javax.ejb.ScheduleExpression)51 ArrayList (java.util.ArrayList)48 EJBCronTrigger (org.apache.openejb.core.timer.EJBCronTrigger)42 HashMap (java.util.HashMap)41 ParseException (java.text.ParseException)39 TimeZone (java.util.TimeZone)38 SimpleTimeZone (java.util.SimpleTimeZone)35 BigDecimal (java.math.BigDecimal)32 Date (java.sql.Date)30 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)28 SQLException (java.sql.SQLException)20 DateFormat (java.text.DateFormat)18 IOException (java.io.IOException)16 Map (java.util.Map)16