Package com.ibm.icu.util

Examples of com.ibm.icu.util.GregorianCalendar


      assertFalse("An exception was not supposed to be thorwn", true);
    }
  }

  public void testCalendarConstructor() {
    GregorianCalendar calendar = new GregorianCalendar(2006, 1, 1, 21, 24, 25);
    calendar.set(GregorianCalendar.MILLISECONDS_IN_DAY, 222);
    DateTimeValue value = null;
    calendar.setTimeZone(TimeZone.getTimeZone("IST"));
    // Check exception thrown for non GMT time zone.
    try {
      value = new DateTimeValue(calendar);
      fail();
    } catch (IllegalArgumentException iae) {
      // do nothing
    }
    calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
    // Check exception not thrown for GMT time zone.
    try {
      value = new DateTimeValue(calendar);
    } catch (IllegalArgumentException iae) {
      fail();
View Full Code Here


  public void testGetValueToFormat() {
    DateTimeValue val = new DateTimeValue(2020, 3, 12, 2, 31, 12, 111);
    DateTimeValue valNull = DateTimeValue.getNullValue();

    GregorianCalendar g = new GregorianCalendar(2020, 3, 12, 2, 31, 12);
    g.set(GregorianCalendar.MILLISECOND, 111);
    g.setTimeZone(TimeZone.getTimeZone("GMT"));

    assertNull(valNull.getObjectToFormat());
    assertEquals(g, val.getObjectToFormat());
  }
View Full Code Here

      assertFalse("An exception was not supposed to be thorwn"true);
    }
  }

  public void testCalendarConstructor() {
    GregorianCalendar calendar = new GregorianCalendar(2006, 1, 3);
    DateValue value = null;
    calendar.setTimeZone(TimeZone.getTimeZone("IST"));
    // Check exception thrown for non GMT time zone.
    try {
      value = new DateValue(calendar);
      fail();
    } catch (IllegalArgumentException iae) {
      // Expected behavior.
    }
    calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
    // Check that an exception is not thrown for GMT time zone.
    try {
      value = new DateValue(calendar);
    } catch (IllegalArgumentException iae) {
      fail();
View Full Code Here

  public void testGetValueToFormat() {
    DateValue val = new DateValue(500, 2, 30);
    DateValue valNull = DateValue.getNullValue();

    assertNull(valNull.getObjectToFormat());
    GregorianCalendar g = new GregorianCalendar(500, 2, 30);
    g.setTimeZone(TimeZone.getTimeZone("GMT"));
    assertEquals(g, val.getObjectToFormat());

  }
View Full Code Here

  }

  public void testCalendarConstructor() {
    // All fields are set in the calendar although only hour, minute and seconds
    // are requried.
    GregorianCalendar calendar = new GregorianCalendar(2006, 1, 1, 21, 24, 25);
    TimeOfDayValue value = null;
    calendar.setTimeZone(TimeZone.getTimeZone("IST"));
    // Check exception thrown for non GMT time zone.
    try {
      value = new TimeOfDayValue(calendar);
      fail();
    } catch (IllegalArgumentException iae) {
      // do nothing
    }
    calendar.setTimeZone(TimeZone.getTimeZone("GMT"));
    // Check exception not thrown for GMT time zone.
    try {
      value = new TimeOfDayValue(calendar);
    } catch (IllegalArgumentException iae) {
      fail();
    }
    // Verify values - default milliseconds.
    assertEquals(21, value.getHours());
    assertEquals(24, value.getMinutes());
    assertEquals(25, value.getSeconds());
    assertEquals(0, value.getMilliseconds());

    // Non default milliseconds.
    calendar.set(GregorianCalendar.MILLISECOND, 123);
    value = new TimeOfDayValue(calendar);
    assertEquals(123, value.getMilliseconds());
  }
View Full Code Here

  public void testGetValueToFormat() {
    TimeOfDayValue val1 = new TimeOfDayValue(12, 23, 12, 111);
    TimeOfDayValue nullVal = TimeOfDayValue.getNullValue();

    assertNull(nullVal.getObjectToFormat());
    GregorianCalendar cal = new GregorianCalendar(1899, 11, 30, 12, 23, 12);
    cal.set(Calendar.MILLISECOND, 111);
    cal.setTimeZone(TimeZone.getTimeZone("GMT"));
    assertEquals(cal, val1.getObjectToFormat());
  }
View Full Code Here

        break;
      case DATE:
        Date date = rs.getDate(column);
        // If date is null it is handled later.
        if (date != null) {
          GregorianCalendar gc =
              new GregorianCalendar(TimeZone.getTimeZone("GMT"));
          // Set the year, month and date in the gregorian calendar.
          // Use the 'set' method with those parameters, and not the 'setTime'
          // method with the date parameter, since the Date object contains the
          // current time zone and it's impossible to change it to 'GMT'.
          gc.set(date.getYear() + 1900, date.getMonth(), date.getDate());
          value = new DateValue(gc);
        }
        break;
      case DATETIME:
        Timestamp timestamp = rs.getTimestamp(column);
        // If timestamp is null it is handled later.
        if (timestamp != null) {
          GregorianCalendar gc =
              new GregorianCalendar(TimeZone.getTimeZone("GMT"));
          // Set the year, month, date, hours, minutes and seconds in the
          // gregorian calendar. Use the 'set' method with those parameters,
          // and not the 'setTime' method with the timestamp parameter, since
          // the Timestamp object contains the current time zone and it's
          // impossible to change it to 'GMT'.
          gc.set(timestamp.getYear() + 1900, timestamp.getMonth(),
                 timestamp.getDate(), timestamp.getHours(), timestamp.getMinutes(),
                 timestamp.getSeconds());
          // Set the milliseconds explicitly, as they are not saved in the
          // underlying date.
          gc.set(Calendar.MILLISECOND, timestamp.getNanos() / 1000000);
          value = new DateTimeValue(gc);
        }
        break;
      case TIMEOFDAY:
        Time time = rs.getTime(column);
        // If time is null it is handled later.
        if (time != null) {
          GregorianCalendar gc =
              new GregorianCalendar(TimeZone.getTimeZone("GMT"));
          // Set the hours, minutes and seconds of the time in the gregorian
          // calendar. Set the year, month and date to be January 1 1970 like
          // in the Time object.
          // Use the 'set' method with those parameters,
          // and not the 'setTime' method with the time parameter, since
          // the Time object contains the current time zone and it's
          // impossible to change it to 'GMT'.
          gc.set(1970, Calendar.JANUARY, 1, time.getHours(), time.getMinutes(),
                 time.getSeconds());
          // Set the milliseconds explicitly, otherwise the milliseconds from
          // the time the gc was initialized are used.
          gc.set(GregorianCalendar.MILLISECOND, 0);
          value = new TimeOfDayValue(gc);
        }
        break;
      default:
        String colValue = rs.getString(column);
View Full Code Here

    {
      Time cleanupTime = systemConfigManager.getTime("phone", "journalCleanupTime");
      int cleanupInterval = systemConfigManager.getInt("phone", "journalCleanupPeriod");
      logger.info("Starting Journal cleanup job (at " + cleanupTime + ", delete entries older than "
              + cleanupInterval + " seconds)");
      GregorianCalendar cleanupTimeCal = new GregorianCalendar();
      cleanupTimeCal.setTime(cleanupTime);
      Runnable cleanupTask = new Runnable()
      {
        @Override
        public void run()
        {
          journalCleanup();
        }
      };
      scheduler.scheduleRunnable(
              "de.iritgo.aktera.journal.JournalCleanup",
              "JournalManager",
              cleanupTask,
              new ScheduleOn().hour(cleanupTimeCal.get(Calendar.HOUR_OF_DAY))
                      .minute(cleanupTimeCal.get(Calendar.MINUTE)).second(0));
    }
  }
View Full Code Here

    public static void main(String args[]) throws Exception {
        new HolidayTest().run(args);
    }
    protected void init()throws Exception{
        if(cal==null){
            cal = new GregorianCalendar(1, 0, 1);
            longTimeAgo = cal.getTime();
            now = new Date();
        }
    }
View Full Code Here

    public void TestIsOn() {
        // jb 1901
        SimpleHoliday sh = new SimpleHoliday(Calendar.AUGUST, 15, "Doug's Day", 1958, 2058);
       
        Calendar gcal = new GregorianCalendar();
        gcal.clear();
        gcal.set(Calendar.YEAR, 2000);
        gcal.set(Calendar.MONTH, Calendar.AUGUST);
        gcal.set(Calendar.DAY_OF_MONTH, 15);
       
        Date d0 = gcal.getTime();
        gcal.add(Calendar.SECOND, 1);
        Date d1 = gcal.getTime();
        gcal.add(Calendar.SECOND, -2);
        Date d2 = gcal.getTime();
        gcal.add(Calendar.DAY_OF_MONTH, 1);
        Date d3 = gcal.getTime();
        gcal.add(Calendar.SECOND, 1);
        Date d4 = gcal.getTime();
        gcal.add(Calendar.SECOND, -2);
        gcal.set(Calendar.YEAR, 1957);
        Date d5 = gcal.getTime();
        gcal.set(Calendar.YEAR, 1958);
        Date d6 = gcal.getTime();
        gcal.set(Calendar.YEAR, 2058);
        Date d7 = gcal.getTime();
        gcal.set(Calendar.YEAR, 2059);
        Date d8 = gcal.getTime();

        Date[] dates = { d0, d1, d2, d3, d4, d5, d6, d7, d8 };
        boolean[] isOns = { true, true, false, true, false, false, true, true, false };
        for (int i = 0; i < dates.length; ++i) {
            Date d = dates[i];
View Full Code Here

TOP

Related Classes of com.ibm.icu.util.GregorianCalendar

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.