Package com.ibm.icu.util

Examples of com.ibm.icu.util.Calendar$PatternData


   
    subscriptionController = new ContextualSubscriptionController(ureq, getWindowControl(), subContext, publisherData);
    listenTo(subscriptionController);
    mainVC.put("newUsersSubscription", subscriptionController.getInitialComponent());
   
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.MONTH, -1);
    dateChooserController = new DateChooserController(ureq, wControl, cal.getTime());
    listenTo(dateChooserController);
    mainVC.put("dateChooser", dateChooserController.getInitialComponent());
   
    updateUI(ureq, cal.getTime());
    putInitialPanel(mainVC);
  }
View Full Code Here


     
      log.audit("+-----------------------------------------------------------------------------+");
      log.audit("+... Update the latest emailed date for all subscribers                       +");
      log.audit("+-----------------------------------------------------------------------------+");
      DBQuery query = DBFactory.getInstance().createQuery("update " + Subscriber.class.getName() + " subscriber set subscriber.latestEmailed=:latestDate");
      Calendar cal = Calendar.getInstance();
      //
      // use the day of installing the release,
      // and set the time back to midnight instead of
      // going back one day, e.g. cal.add(Calendar.DAY_OF_MONTH, -1);
      //
      // 1) before release day, sending notifications the old way at 02:00:00 a.m.
      // 2) at release day, sending notifications the old way at 02:00:00 a.m.
      // .. Install the Release -> Upgrader sets latestEmail sent on subscribers to release day at 00:00:00
      // 3) day after release, sending notifications the new way at 02:00:00 a.m.
      //
      // with this procedure only the news are sent twice which were created between 00:00:00 and 02:00:00 of release day.
      //
      cal.set(Calendar.HOUR_OF_DAY, 0);
      cal.set(Calendar.MINUTE, 0);
      cal.set(Calendar.SECOND, 0);
      cal.set(Calendar.MILLISECOND, 0);
      query.setTimestamp("latestDate", cal.getTime());
      int subCounter = query.executeUpdate(FlushMode.AUTO);
     
      DBFactory.getInstance().intermediateCommit();
      log.audit("**** Migrated " + subCounter + " subscribers. ****");

 
View Full Code Here

  private final int millisInAMinute = 1000 * 60;
  private final int millisInAnHour = millisInAMinute * 60;

  private IValue incrementDTField(IDateTime dt, int field, IInteger amount) {
    Calendar cal = null;

    cal = dateTimeToCalendar(dt);
   
    // Make sure lenient is true, since this allows wrapping of fields. For
    // instance, if you have $2012-05-15, and subtract 15 months, this is
    // an error if lenient is false, but gives $2012-02-15 (as expected)
    // if lenient is true.
    cal.setLenient(true);

    cal.add(field, amount.intValue());

    // Turn the calendar back into a date, time, or datetime value
    if (dt.isDate()) {
      return calendarToDate(cal);
    } else {
View Full Code Here

        values.integer(cal.get(Calendar.MONTH)+1),
        values.integer(cal.get(Calendar.DAY_OF_MONTH)));
  }

  private Calendar dateTimeToCalendar(IDateTime dt) {
    Calendar cal;
    if (dt.isDate()) {
      cal = Calendar.getInstance(TimeZone.getDefault(), Locale.getDefault());
      cal.set(dt.getYear(), dt.getMonthOfYear()-1, dt.getDayOfMonth());
    } else {
      cal = Calendar.getInstance(TimeZone.getTimeZone(getTZString(dt.getTimezoneOffsetHours(), dt.getTimezoneOffsetMinutes())),Locale.getDefault());
      if (dt.isTime()) {
        cal.set(1970, 0, 1, dt.getHourOfDay(), dt.getMinuteOfHour(), dt.getSecondOfMinute());
      } else {
        cal.set(dt.getYear(), dt.getMonthOfYear()-1, dt.getDayOfMonth(), dt.getHourOfDay(), dt.getMinuteOfHour(), dt.getSecondOfMinute());
      }
      cal.set(Calendar.MILLISECOND, dt.getMillisecondsOfSecond());
    }
    return cal;
  }
View Full Code Here

    return incrementTime(dt, Calendar.MILLISECOND, "milliseconds", n.negate());
  }   

  public IValue createDurationInternal(IDateTime dStart, IDateTime dEnd) {
    // dStart and dEnd both have to be dates, times, or datetimes
    Calendar startCal = Calendar.getInstance();
    startCal.setTimeInMillis(dStart.getInstant());
    Calendar endCal = Calendar.getInstance();
    endCal.setTimeInMillis(dEnd.getInstant());
   
    IValue duration = null;
    if (dStart.isDate()) {
      if (dEnd.isDate()) {
        duration = values.tuple(
            values.integer(startCal.fieldDifference(endCal.getTime(), Calendar.YEAR)),
            values.integer(startCal.fieldDifference(endCal.getTime(), Calendar.MONTH)),
            values.integer(startCal.fieldDifference(endCal.getTime(), Calendar.DAY_OF_MONTH)),
            values.integer(0), values.integer(0), values.integer(0),
            values.integer(0));
      } else if (dEnd.isTime()) {
        throw RuntimeExceptionFactory.invalidUseOfTimeException("Cannot determine the duration between a date with no time and a time with no date.", null, null)
      } else {
        throw RuntimeExceptionFactory.invalidUseOfDateTimeException("Cannot determine the duration between a date with no time and a datetime.", null, null);         
      }
    } else if (dStart.isTime()) {
      if (dEnd.isTime()) {
        duration = values.tuple(
            values.integer(0),
            values.integer(0),
            values.integer(0),
            values.integer(startCal.fieldDifference(endCal.getTime(), Calendar.HOUR_OF_DAY)),
            values.integer(startCal.fieldDifference(endCal.getTime(), Calendar.MINUTE)),
            values.integer(startCal.fieldDifference(endCal.getTime(), Calendar.SECOND)),
            values.integer(startCal.fieldDifference(endCal.getTime(), Calendar.MILLISECOND)));
      } else if (dEnd.isDate()) {
        throw RuntimeExceptionFactory.invalidUseOfDateException("Cannot determine the duration between a time with no date and a date with no time.", null, null)
      } else {
        throw RuntimeExceptionFactory.invalidUseOfDateTimeException("Cannot determine the duration between a time with no date and a datetime.", null, null);         
      }
    } else {
      if (dEnd.isDateTime()) {
        duration = values.tuple(
            values.integer(startCal.fieldDifference(endCal.getTime(), Calendar.YEAR)),
            values.integer(startCal.fieldDifference(endCal.getTime(), Calendar.MONTH)),
            values.integer(startCal.fieldDifference(endCal.getTime(), Calendar.DAY_OF_MONTH)),
            values.integer(startCal.fieldDifference(endCal.getTime(), Calendar.HOUR_OF_DAY)),
            values.integer(startCal.fieldDifference(endCal.getTime(), Calendar.MINUTE)),
            values.integer(startCal.fieldDifference(endCal.getTime(), Calendar.SECOND)),
            values.integer(startCal.fieldDifference(endCal.getTime(), Calendar.MILLISECOND)));
      } else if (dEnd.isDate()) {
        throw RuntimeExceptionFactory.invalidUseOfDateException("Cannot determine the duration between a datetime and a date with no time.", null, null)
      } else {
        throw RuntimeExceptionFactory.invalidUseOfTimeException("Cannot determine the duration between a datetime and a time with no date.", null, null);         
      }
View Full Code Here

    }
  }

  private Calendar getCalendarForDate(IDateTime inputDate) {
    if (inputDate.isDate() || inputDate.isDateTime()) {
      Calendar cal = Calendar.getInstance(TimeZone.getDefault(),Locale.getDefault());
      cal.setLenient(false);
      cal.set(inputDate.getYear(), inputDate.getMonthOfYear()-1, inputDate.getDayOfMonth());
      return cal;
    } else {
      throw new IllegalArgumentException("Cannot get date for a datetime that only represents the time");
    }
  }
View Full Code Here

    }
  }
 
  private Calendar getCalendarForTime(IDateTime inputTime) {
    if (inputTime.isTime() || inputTime.isDateTime()) {
      Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(getTZString(inputTime.getTimezoneOffsetHours(),inputTime.getTimezoneOffsetMinutes())),Locale.getDefault());
      cal.setLenient(false);
      cal.set(Calendar.HOUR_OF_DAY, inputTime.getHourOfDay());
      cal.set(Calendar.MINUTE, inputTime.getMinuteOfHour());
      cal.set(Calendar.SECOND, inputTime.getSecondOfMinute());
      cal.set(Calendar.MILLISECOND, inputTime.getMillisecondsOfSecond());
      return cal;
    } else {
      throw new IllegalArgumentException("Cannot get time for a datetime that only represents the date");
    }
  }
View Full Code Here

    }
  }

  private Calendar getCalendarForDateTime(IDateTime inputDateTime) {
    if (inputDateTime.isDateTime()) {
      Calendar cal = Calendar.getInstance(TimeZone.getTimeZone(getTZString(inputDateTime.getTimezoneOffsetHours(),inputDateTime.getTimezoneOffsetMinutes())),Locale.getDefault());
      cal.setLenient(false);
      cal.set(inputDateTime.getYear(), inputDateTime.getMonthOfYear()-1, inputDateTime.getDayOfMonth(), inputDateTime.getHourOfDay(), inputDateTime.getMinuteOfHour(), inputDateTime.getSecondOfMinute());
      cal.set(Calendar.MILLISECOND, inputDateTime.getMillisecondsOfSecond());
      return cal;
    } else {
      throw new IllegalArgumentException("Cannot get date and time for a datetime that only represents the date or the time");
    }
  }
View Full Code Here

  public IValue printDate(IDateTime inputDate, IString formatString)
  //@doc{Print an input date using the given format string}
  {
    try {
      SimpleDateFormat sd = new SimpleDateFormat(formatString.getValue());
      Calendar cal = getCalendarForDate(inputDate);
      sd.setCalendar(cal);
      return values.string(sd.format(cal.getTime()));
    } catch (IllegalArgumentException iae) {
      throw RuntimeExceptionFactory.dateTimePrintingError("Cannot print time with format " + formatString.getValue(), null, null);
    }
  }
View Full Code Here

  public IValue printDate(IDateTime inputDate)
  //@doc{Print an input date using a default format string}
  {
    SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
    Calendar cal = getCalendarForDate(inputDate);
    sd.setCalendar(cal);
    return values.string(sd.format(cal.getTime()));
  }
View Full Code Here

TOP

Related Classes of com.ibm.icu.util.Calendar$PatternData

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.