Search in sources :

Example 31 with GregorianCalendar

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

the class GregorianCalendarTest method test_getLeastMaximumI.

/**
     * java.util.GregorianCalendar#getLeastMaximum(int)
     */
public void test_getLeastMaximumI() {
    // Test for method int java.util.GregorianCalendar.getLeastMaximum(int)
    GregorianCalendar gc = new GregorianCalendar();
    assertEquals("Wrong least maximum value for DAY_OF_MONTH", 28, gc.getLeastMaximum(Calendar.DAY_OF_MONTH));
    assertTrue("Wrong least maximum value for MONTH", gc.getLeastMaximum(Calendar.MONTH) == Calendar.DECEMBER);
    assertEquals("Wrong least maximum value for HOUR_OF_DAY", 23, gc.getLeastMaximum(Calendar.HOUR_OF_DAY));
    assertEquals("Wrong least maximum value for HOUR", 11, gc.getLeastMaximum(Calendar.HOUR));
    BitSet result = new BitSet();
    Vector values = new Vector();
    int[] max = { 1, 292269054, 11, 50, 3, 28, 355, 7, 3, 1, 11, 23, 59, 59, 999, 50400000, 1200000 };
    for (int i = 0; i < max.length; i++) {
        if (gc.getLeastMaximum(i) != max[i]) {
            result.set(i);
            values.add(new Integer(gc.getLeastMaximum(i)));
        }
    }
    assertTrue("Wrong least max for " + result + " = " + values, result.length() == 0);
}
Also used : GregorianCalendar(java.util.GregorianCalendar) BitSet(java.util.BitSet) Vector(java.util.Vector)

Example 32 with GregorianCalendar

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

the class GregorianCalendarTest method test_ConstructorLjava_util_TimeZone.

/**
     * java.util.GregorianCalendar#GregorianCalendar(java.util.TimeZone)
     */
public void test_ConstructorLjava_util_TimeZone() {
    // Test for method java.util.GregorianCalendar(java.util.TimeZone)
    Date date = new Date(2008, 1, 1);
    TimeZone.getDefault();
    GregorianCalendar gc1 = new GregorianCalendar(AMERICA_NEW_YORK);
    gc1.setTime(date);
    GregorianCalendar gc2 = new GregorianCalendar(AMERICA_CHICAGO);
    gc2.setTime(date);
    // Chicago is 1 hour before New York, add 1 to the Chicago time and convert to 0-12 value
    assertEquals("Incorrect calendar returned", gc1.get(Calendar.HOUR), ((gc2.get(Calendar.HOUR) + 1) % 12));
    // Regression test for HARMONY-2961
    SimpleTimeZone timezone = new SimpleTimeZone(-3600 * 24 * 1000 * 2, "GMT");
    GregorianCalendar gc = new GregorianCalendar(timezone);
    // Regression test for HARMONY-5195
    Calendar c1 = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
    c1.set(Calendar.YEAR, 1999);
    c1.set(Calendar.MONTH, Calendar.JUNE);
    c1.set(Calendar.DAY_OF_MONTH, 2);
    c1.set(Calendar.HOUR, 15);
    c1.set(Calendar.MINUTE, 34);
    c1.set(Calendar.SECOND, 16);
    assertEquals(34, c1.get(Calendar.MINUTE));
    c1.setTimeZone(new SimpleTimeZone(60000, "ONE MINUTE"));
    assertEquals(35, c1.get(Calendar.MINUTE));
}
Also used : SimpleTimeZone(java.util.SimpleTimeZone) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) Date(java.util.Date)

Example 33 with GregorianCalendar

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

the class GregorianCalendarTest method test_setGregorianChangeLjava_util_Date.

/**
     * java.util.GregorianCalendar#setGregorianChange(java.util.Date)
     */
public void test_setGregorianChangeLjava_util_Date() {
    // Test for method void
    // java.util.GregorianCalendar.setGregorianChange(java.util.Date)
    GregorianCalendar gc1 = new GregorianCalendar(1582, Calendar.OCTOBER, 4, 0, 0);
    GregorianCalendar gc2 = new GregorianCalendar(1972, Calendar.OCTOBER, 13, 0, 0);
    gc1.setGregorianChange(gc2.getTime());
    assertTrue("Returned incorrect value", gc2.getTime().equals(gc1.getGregorianChange()));
}
Also used : GregorianCalendar(java.util.GregorianCalendar)

Example 34 with GregorianCalendar

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

the class GregorianCalendarTest method test_getActualMinimumI.

/**
     * java.util.GregorianCalendar#getActualMinimum(int)
     */
public void test_getActualMinimumI() {
    // Test for method int java.util.GregorianCalendar.getActualMinimum(int)
    GregorianCalendar gc1 = new GregorianCalendar(1900, 1, 1);
    new GregorianCalendar(1996, 1, 1);
    new GregorianCalendar(1997, 1, 1);
    new GregorianCalendar(2000, 1, 1);
    new GregorianCalendar(2000, 9, 9);
    GregorianCalendar gc6 = new GregorianCalendar(2000, 3, 3);
    assertEquals("Wrong actual minimum value for DAY_OF_MONTH for Feb 1900", 1, gc1.getActualMinimum(Calendar.DAY_OF_MONTH));
    assertTrue("Wrong actual minimum value for MONTH", gc1.getActualMinimum(Calendar.MONTH) == Calendar.JANUARY);
    assertEquals("Wrong actual minimum value for HOUR_OF_DAY", 0, gc1.getActualMinimum(Calendar.HOUR_OF_DAY));
    assertEquals("Wrong actual minimum value for HOUR", 0, gc1.getActualMinimum(Calendar.HOUR));
    assertEquals("Wrong actual minimum value for DAY_OF_WEEK_IN_MONTH", 1, gc6.getActualMinimum(Calendar.DAY_OF_WEEK_IN_MONTH));
}
Also used : GregorianCalendar(java.util.GregorianCalendar)

Example 35 with GregorianCalendar

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

the class GregorianCalendarTest method test_computeTime.

/**
     * java.util.GregorianCalendar#computeTime()
     */
public void test_computeTime() {
    // Regression for Harmony-493
    GregorianCalendar g = new GregorianCalendar(TimeZone.getTimeZone("Europe/London"), new Locale("en", "GB"));
    g.clear();
    g.set(2006, Calendar.MARCH, 26, 01, 50, 00);
    assertEquals(1143337800000L, g.getTimeInMillis());
    GregorianCalendar g1 = new GregorianCalendar(TimeZone.getTimeZone("Europe/Moscow"));
    g1.clear();
    g1.set(2006, Calendar.MARCH, 26, 02, 20, 00);
    assertEquals(1143328800000L, g1.getTimeInMillis());
    assertEquals(3, g1.get(Calendar.HOUR_OF_DAY));
    assertEquals(20, g1.get(Calendar.MINUTE));
    g1.clear();
    g1.set(2006, Calendar.OCTOBER, 29, 02, 50, 00);
    assertEquals(1162079400000L, g1.getTimeInMillis());
    assertEquals(2, g1.get(Calendar.HOUR_OF_DAY));
    assertEquals(50, g1.get(Calendar.MINUTE));
// End of regression test
}
Also used : Locale(java.util.Locale) 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