Search in sources :

Example 66 with GregorianCalendar

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

the class SimpleDateFormatTest method test_parse_dayOfYearPatterns.

public void test_parse_dayOfYearPatterns() throws Exception {
    GregorianCalendar cal = new GregorianCalendar(1970, Calendar.JANUARY, 1);
    cal.setTimeZone(TimeZone.getTimeZone("GMT+0:1"));
    cal.set(Calendar.DAY_OF_YEAR, 243);
    assertParse("D z", "243 GMT+00:00", cal.getTime(), 0, 13);
}
Also used : GregorianCalendar(java.util.GregorianCalendar)

Example 67 with GregorianCalendar

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

the class SimpleDateFormatTest method test_timeZoneFormatting.

public void test_timeZoneFormatting() {
    // tests specific to formatting of timezones
    Date summerDate = new GregorianCalendar(1999, Calendar.JUNE, 2, 15, 3, 6).getTime();
    Date winterDate = new GregorianCalendar(1999, Calendar.JANUARY, 12).getTime();
    verifyFormatTimezone("America/Los_Angeles", "PDT, Pacific Daylight Time", "-0700, GMT-07:00", summerDate);
    verifyFormatTimezone("America/Los_Angeles", "PST, Pacific Standard Time", "-0800, GMT-08:00", winterDate);
    verifyFormatTimezone("GMT-7", "GMT-07:00, GMT-07:00", "-0700, GMT-07:00", summerDate);
    verifyFormatTimezone("GMT-7", "GMT-07:00, GMT-07:00", "-0700, GMT-07:00", winterDate);
    verifyFormatTimezone("GMT+14", "GMT+14, GMT+14:00", "+1400, GMT+14:00", summerDate);
    verifyFormatTimezone("GMT+14", "GMT+14, GMT+14:00", "+1400, GMT+14:00", winterDate);
    // this fails on the RI!
    verifyFormatTimezone("America/Detroit", "EDT, Eastern Daylight Time", "-0400, GMT-04:00", summerDate);
    verifyFormatTimezone("America/Detroit", "EST, Eastern Standard Time", "-0500, GMT-05:00", winterDate);
    // Pacific/Kiritimati is one of the timezones supported only in mJava
    verifyFormatTimezone("Pacific/Kiritimati", "GMT+14, Line Islands Time", "+1400, GMT+14:00", summerDate);
    verifyFormatTimezone("Pacific/Kiritimati", "GMT+14, Line Islands Time", "+1400, GMT+14:00", winterDate);
    verifyFormatTimezone("EST", "GMT-5, GMT-05:00", "-0500, GMT-05:00", summerDate);
    verifyFormatTimezone("EST", "GMT-5, GMT-05:00", "-0500, GMT-05:00", winterDate);
    verifyFormatTimezone("GMT+14", "GMT+14, GMT+14:00", "+1400, GMT+14:00", summerDate);
    verifyFormatTimezone("GMT+14", "GMT+14, GMT+14:00", "+1400, GMT+14:00", winterDate);
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Date(java.util.Date)

Example 68 with GregorianCalendar

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

the class SimpleDateFormatTest method testNonDstZoneWithDstTimestampForNonHourDstZone.

public void testNonDstZoneWithDstTimestampForNonHourDstZone() throws Exception {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm zzzz", Locale.US);
    Calendar calendar = new GregorianCalendar(AUSTRALIA_LORD_HOWE);
    //9:00 GMT+10:30
    calendar.setTime(format.parse("2010-12-21T19:30 Lord Howe Standard Time"));
    // 9:00 GMT+11:00
    assertEquals(20, calendar.get(Calendar.HOUR_OF_DAY));
    assertEquals(0, calendar.get(Calendar.MINUTE));
}
Also used : Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) SimpleDateFormat(java.text.SimpleDateFormat)

Example 69 with GregorianCalendar

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

the class SimpleDateFormatTest method testDstZoneNameWithNonDstTimestamp.

public void testDstZoneNameWithNonDstTimestamp() throws Exception {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm zzzz", Locale.US);
    Calendar calendar = new GregorianCalendar(AMERICA_LOS_ANGELES);
    // 18:00 GMT-8
    calendar.setTime(format.parse("2011-06-21T10:00 Pacific Standard Time"));
    // 18:00 GMT-7
    assertEquals(11, calendar.get(Calendar.HOUR_OF_DAY));
    assertEquals(0, calendar.get(Calendar.MINUTE));
}
Also used : Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) SimpleDateFormat(java.text.SimpleDateFormat)

Example 70 with GregorianCalendar

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

the class SimpleDateFormatTest method testDstZoneWithNonDstTimestampForNonHourDstZone.

// http://b/4723412
public void testDstZoneWithNonDstTimestampForNonHourDstZone() throws Exception {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm zzzz", Locale.US);
    Calendar calendar = new GregorianCalendar(AUSTRALIA_LORD_HOWE);
    // 9:00 GMT+11
    calendar.setTime(format.parse("2011-06-21T20:00 Lord Howe Daylight Time"));
    // 9:00 GMT+10:30
    assertEquals(19, calendar.get(Calendar.HOUR_OF_DAY));
    assertEquals(30, calendar.get(Calendar.MINUTE));
}
Also used : Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) GregorianCalendar(java.util.GregorianCalendar) SimpleDateFormat(java.text.SimpleDateFormat)

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