Java Code Examples for net.fortuna.ical4j.model.Recur#getUntil()

The following examples show how to use net.fortuna.ical4j.model.Recur#getUntil() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Calendar_EventRepeatMaster.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 获取重复时间表达式中结束的日期
 * @return
 */
public Date getRecurrenceEndDate() {
	final TimeZone tz = TimeZoneRegistryFactory.getInstance().createRegistry()
			.getTimeZone(java.util.Calendar.getInstance().getTimeZone().getID());
	if (recurrenceRule != null) {
		try {
			final Recur recur = new Recur(recurrenceRule);
			final Date dUntil = recur.getUntil();
			final DateTime dtUntil = dUntil == null ? null : new DateTime(dUntil.getTime());
			if (dtUntil != null) {
				dtUntil.setTimeZone(tz);
				return dtUntil;
			}
		} catch (final ParseException e) {
			System.out.println("cannot restore recurrence rule");
			e.printStackTrace();
		}
	}
	return null;
}
 
Example 2
Source File: CalendarEntry.java    From olat with Apache License 2.0 6 votes vote down vote up
/**
 * @param rule
 * @return date of recurrence end
 */
public Date getRecurrenceEndDate() {
    final TimeZone tz = TimeZoneRegistryFactory.getInstance().createRegistry().getTimeZone(java.util.Calendar.getInstance().getTimeZone().getID());

    if (recurrenceRule != null) {
        try {
            final Recur recur = new Recur(recurrenceRule);
            final Date dUntil = recur.getUntil();
            final DateTime dtUntil = dUntil == null ? null : new DateTime(dUntil.getTime());
            if (dtUntil != null) {
                dtUntil.setTimeZone(tz);
                return dtUntil;
            }
        } catch (final ParseException e) {
            log.error("cannot restore recurrence rule", e);
        }
    }

    return null;
}
 
Example 3
Source File: CalendarEntry.java    From olat with Apache License 2.0 6 votes vote down vote up
/**
 * @param rule
 * @return date of recurrence end
 */
public Date getRecurrenceEndDate() {
    final TimeZone tz = TimeZoneRegistryFactory.getInstance().createRegistry().getTimeZone(java.util.Calendar.getInstance().getTimeZone().getID());

    if (recurrenceRule != null) {
        try {
            final Recur recur = new Recur(recurrenceRule);
            final Date dUntil = recur.getUntil();
            final DateTime dtUntil = dUntil == null ? null : new DateTime(dUntil.getTime());
            if (dtUntil != null) {
                dtUntil.setTimeZone(tz);
                return dtUntil;
            }
        } catch (final ParseException e) {
            log.error("cannot restore recurrence rule", e);
        }
    }

    return null;
}
 
Example 4
Source File: ICal4JUtils.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 
 * @param rruleString
 * @return null if rruleString is empty, otherwise new RRule object.
 */
public static RRule calculateRecurrenceRule(final String rruleString)
{
  if (StringUtils.isBlank(rruleString) == true) {
    return null;
  }
  try {
    final RRule rule = new RRule(rruleString);
    // set the recurrence end date to the last minute of the day
    final Recur recur = rule.getRecur();
    final net.fortuna.ical4j.model.Date until = recur != null ? recur.getUntil() : null;
    if (until != null) {
      final Date untilEndOfDay = CalendarUtils.getEndOfDay(until, PFUserContext.getTimeZone());
      recur.setUntil(new net.fortuna.ical4j.model.Date(untilEndOfDay));
    }
    return rule;
  } catch (final ParseException ex) {
    log.error("Exception encountered while parsing rrule '" + rruleString + "': " + ex.getMessage(), ex);
    return null;
  }
}
 
Example 5
Source File: ICal4JUtils.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public static Date calculateRecurrenceUntil(final String rruleString)
{
  if (StringUtils.isBlank(rruleString) == true) {
    return null;
  }
  final Recur recur = calculateRecurrence(rruleString);
  if (recur == null) {
    return null;
  }
  return recur.getUntil();
}
 
Example 6
Source File: TeamEventRecurrenceData.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public TeamEventRecurrenceData(final Recur recur, final TimeZone timeZone)
{
  this.timeZone = timeZone;
  if (recur == null) {
    return;
  }
  this.interval = recur.getInterval();
  if (this.interval < 1) {
    this.interval = 1;
  }
  if (recur.getUntil() != null) {
    this.until = CalendarUtils.getEndOfDay(recur.getUntil(), timeZone);
  }
  this.frequency = ICal4JUtils.getFrequency(recur);
}