net.fortuna.ical4j.model.WeekDay类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(110)

本文整理了Java中net.fortuna.ical4j.model.WeekDay类的一些代码示例,展示了WeekDay类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WeekDay类的具体详情如下:
包路径:net.fortuna.ical4j.model.WeekDay
类名称:WeekDay

WeekDay介绍

[英]$Id$ Created: 19/12/2004 Defines a day of the week with a possible offset related to a MONTHLY or YEARLY occurrence.
[中]$Id$Created:19/12/2004定义了一周中的某一天,该天可能与每月或每年发生的事件有关。

代码示例

代码示例来源:origin: ical4j/ical4j

/**
 * {@inheritDoc}
 */
public final boolean equals(final Object arg0) {
  if (arg0 == null) {
    return false;
  }
  if (!(arg0 instanceof WeekDay)) {
    return false;
  }
  final WeekDay wd = (WeekDay) arg0;
  return Objects.equals(wd.getDay(), getDay())
    && wd.getOffset() == getOffset();
}

代码示例来源:origin: net.oneandone.ical4j/ical4j

/**
 * Returns a weekday representation of the specified calendar.
 * @param cal a calendar (java.util)
 * @return a weekday instance representing the specified calendar
 */
public static WeekDay getWeekDay(final Calendar cal) {
  return new WeekDay(getDay(cal.get(Calendar.DAY_OF_WEEK)), 0);
}

代码示例来源:origin: org.bedework.ical4j/ical4j

/**
 * @param weekStartDay The weekStartDay to set.
 */
public final void setWeekStartDay(final WeekDay.Day weekStartDay) {
  this.weekStartDay = weekStartDay;
  if (weekStartDay != null) {
    calendarWeekStartDay = WeekDay.getCalendarDay(WeekDay.getWeekDay(weekStartDay));
  }
}

代码示例来源:origin: org.bedework/bw-ical4j-cl

/**
 * @param weekStartDay The weekStartDay to set.
 */
public final void setWeekStartDay(final String weekStartDay) {
  this.weekStartDay = weekStartDay;
  if (weekStartDay != null) {
    calendarWeekStartDay = WeekDay.getCalendarDay(new WeekDay(weekStartDay));
  }
}

代码示例来源:origin: ical4j/ical4j

/**
 * Constructs a new weekday instance based on the specified
 * instance and offset.
 * @param weekDay a week day template for the instance
 * @param offset a month offset value
 */
public WeekDay(final WeekDay weekDay, final int offset) {
  this.day = weekDay.getDay();
  this.offset = offset;
}

代码示例来源:origin: ical4j/ical4j

@Override
public DateList transform(DateList dates) {
  if (dayList.isEmpty()) {
    return dates;
  }
  final DateList weekDayDates = Dates.getDateListInstance(dates);
  Function<Date, List<Date>> transformer = null;
  switch (getFrequency()) {
    case WEEKLY: transformer = new WeeklyExpansionFilter(dates.getType()); break;
    case MONTHLY: transformer = new MonthlyExpansionFilter(dates.getType()); break;
    case YEARLY: transformer = new YearlyExpansionFilter(dates.getType()); break;
    case DAILY:
    default: transformer = new LimitFilter();
  }
  for (final Date date : dates) {
    List<Date> transformed = transformer.apply(date);
    // filter by offset
    List<Date> filtered = new ArrayList<>();
    dayList.forEach(day -> filtered.addAll(getOffsetDates(transformed.stream().filter(d ->
      getCalendarInstance(d, true).get(Calendar.DAY_OF_WEEK) == WeekDay.getCalendarDay(day))
      .collect(Collectors.toCollection(() -> Dates.getDateListInstance(weekDayDates))), day.getOffset())));
    weekDayDates.addAll(filtered);
  }
  return weekDayDates;
}

代码示例来源:origin: org.bedework.ical4j/ical4j

/**
 * Constructor.
 * @param aString a string representation of a day list
 */
public WeekDayList(final String aString) {
  final boolean outlookCompatibility =
    CompatibilityHints.isHintEnabled(CompatibilityHints.KEY_OUTLOOK_COMPATIBILITY);
  
  final StringTokenizer t = new StringTokenizer(aString, ",");
  while (t.hasMoreTokens()) {
    if (outlookCompatibility) {
      add(new WeekDay(t.nextToken().replaceAll(" ", "")));
    }
    else {
      add(new WeekDay(t.nextToken()));
    }
  }
}

代码示例来源:origin: org.bedework/bw-ical4j-cl

/**
 * Applies BYDAY rules specified in this Recur instance to the specified date list. If no BYDAY rules are specified
 * the date list is returned unmodified.
 * @param dates
 * @return
 */
private DateList getDayVariants(final DateList dates) {
  if (getDayList().isEmpty()) {
    return dates;
  }
  final DateList weekDayDates = getDateListInstance(dates);
  for (final Iterator i = dates.iterator(); i.hasNext();) {
    final Date date = (Date) i.next();
    for (final Iterator j = getDayList().iterator(); j.hasNext();) {
      final WeekDay weekDay = (WeekDay) j.next();
      // if BYYEARDAY or BYMONTHDAY is specified filter existing
      // list..
      if (!getYearDayList().isEmpty() || !getMonthDayList().isEmpty()) {
        final Calendar cal = getCalendarInstance(date, true);
        if (weekDay.equals(WeekDay.getWeekDay(cal))) {
          weekDayDates.add(date);
        }
      }
      else {
        weekDayDates.addAll(getAbsWeekDays(date, dates.getType(), weekDay));
      }
    }
  }
  return weekDayDates;
}

代码示例来源:origin: ical4j/ical4j

@Override
  public List<Date> apply(Date date) {
    final Calendar cal = getCalendarInstance(date, true);
    if (dayList.contains(WeekDay.getWeekDay(cal))) {
      return Arrays.asList(date);
    }
    return Collections.emptyList();
  }
}

代码示例来源:origin: ical4j/ical4j

/**
   * Tests the parsing of various offset values.
   */
  public void testOffsetParsing() {
    log.info(new WeekDay("-1SU").toString());
    log.info(new WeekDay("+2SU").toString());
  }
}

代码示例来源:origin: ical4j/ical4j

@Override
  public List<Date> apply(Date date) {
    List<Date> retVal = new ArrayList<>();
    final Calendar cal = getCalendarInstance(date, true);
    final int month = cal.get(Calendar.MONTH);
    // construct a list of possible month days..
    cal.set(Calendar.DAY_OF_MONTH, 1);
    while (cal.get(Calendar.MONTH) == month) {
      if (!dayList.stream().map(weekDay -> WeekDay.getCalendarDay(weekDay))
          .filter(calDay -> cal.get(Calendar.DAY_OF_WEEK) == calDay)
          .collect(Collectors.toList()).isEmpty()) {
        retVal.add(Dates.getInstance(cal.getTime(), type));
      }
      cal.add(Calendar.DAY_OF_MONTH, 1);
    }
    return retVal;
  }
}

代码示例来源:origin: org.bedework/bw-ical4j-cl

/**
 * @param value a string representation of a week day
 */
public WeekDay(final String value) {
  if (value.length() > 2) {
    offset = Numbers.parseInt(value.substring(0, value.length() - 2));
  }
  else {
    offset = 0;
  }
  day = value.substring(value.length() - 2);
  validateDay();
}

代码示例来源:origin: net.oneandone.ical4j/ical4j

/**
 * Constructs a new weekday instance based on the specified
 * instance and offset.
 * @param weekDay a week day template for the instance
 * @param offset a month offset value
 */
public WeekDay(final WeekDay weekDay, final int offset) {
  this.day = weekDay.getDay();
  this.offset = offset;
}

代码示例来源:origin: org.mnode.ical4j/ical4j

@Override
public DateList transform(DateList dates) {
  if (dayList.isEmpty()) {
    return dates;
  }
  final DateList weekDayDates = Dates.getDateListInstance(dates);
  Function<Date, List<Date>> transformer = null;
  switch (getFrequency()) {
    case WEEKLY: transformer = new WeeklyExpansionFilter(dates.getType()); break;
    case MONTHLY: transformer = new MonthlyExpansionFilter(dates.getType()); break;
    case YEARLY: transformer = new YearlyExpansionFilter(dates.getType()); break;
    case DAILY:
    default: transformer = new LimitFilter();
  }
  for (final Date date : dates) {
    List<Date> transformed = transformer.apply(date);
    // filter by offset
    List<Date> filtered = new ArrayList<>();
    dayList.forEach(day -> filtered.addAll(getOffsetDates(transformed.stream().filter(d ->
      getCalendarInstance(d, true).get(Calendar.DAY_OF_WEEK) == WeekDay.getCalendarDay(day))
      .collect(Collectors.toCollection(() -> Dates.getDateListInstance(weekDayDates))), day.getOffset())));
    weekDayDates.addAll(filtered);
  }
  return weekDayDates;
}

代码示例来源:origin: org.bedework/bw-ical4j-cl

/**
 * Constructor.
 * @param aString a string representation of a day list
 */
public WeekDayList(final String aString) {
  final boolean outlookCompatibility =
    CompatibilityHints.isHintEnabled(CompatibilityHints.KEY_OUTLOOK_COMPATIBILITY);
  
  final StringTokenizer t = new StringTokenizer(aString, ",");
  while (t.hasMoreTokens()) {
    if (outlookCompatibility) {
      add(new WeekDay(t.nextToken().replaceAll(" ", "")));
    }
    else {
      add(new WeekDay(t.nextToken()));
    }
  }
}

代码示例来源:origin: org.bedework/bw-ical4j-cl

calendarWeekStartDay = WeekDay.getCalendarDay(new WeekDay(weekStartDay));

代码示例来源:origin: org.bedework.ical4j/ical4j

/**
 * Applies BYDAY rules specified in this Recur instance to the specified date list. If no BYDAY rules are specified
 * the date list is returned unmodified.
 *
 * @param dates
 * @return
 */
private DateList getDayVariants(final DateList dates) {
  if (getDayList().isEmpty()) {
    return dates;
  }
  final DateList weekDayDates = getDateListInstance(dates);
  for (final Date date : dates) {
    for (final WeekDay weekDay : getDayList()) {
      // if BYYEARDAY or BYMONTHDAY is specified filter existing
      // list..
      if (!getYearDayList().isEmpty() || !getMonthDayList().isEmpty()) {
        final Calendar cal = getCalendarInstance(date, true);
        if (weekDay.equals(WeekDay.getWeekDay(cal))) {
          weekDayDates.add(date);
        }
      } else {
        weekDayDates.addAll(getAbsWeekDays(date, dates.getType(), weekDay));
      }
    }
  }
  return weekDayDates;
}

代码示例来源:origin: org.mnode.ical4j/ical4j

@Override
  public List<Date> apply(Date date) {
    final Calendar cal = getCalendarInstance(date, true);
    if (dayList.contains(WeekDay.getWeekDay(cal))) {
      return Arrays.asList(date);
    }
    return Collections.emptyList();
  }
}

代码示例来源:origin: org.mnode.ical4j/ical4j

@Override
  public List<Date> apply(Date date) {
    List<Date> retVal = new ArrayList<>();
    final Calendar cal = getCalendarInstance(date, true);
    final int month = cal.get(Calendar.MONTH);
    // construct a list of possible month days..
    cal.set(Calendar.DAY_OF_MONTH, 1);
    while (cal.get(Calendar.MONTH) == month) {
      if (!dayList.stream().map(weekDay -> WeekDay.getCalendarDay(weekDay))
          .filter(calDay -> cal.get(Calendar.DAY_OF_WEEK) == calDay)
          .collect(Collectors.toList()).isEmpty()) {
        retVal.add(Dates.getInstance(cal.getTime(), type));
      }
      cal.add(Calendar.DAY_OF_MONTH, 1);
    }
    return retVal;
  }
}

代码示例来源:origin: net.oneandone.ical4j/ical4j

/**
 * @param value a string representation of a week day
 */
public WeekDay(final String value) {
  if (value.length() > 2) {
    offset = Numbers.parseInt(value.substring(0, value.length() - 2));
  }
  else {
    offset = 0;
  }
  day = Day.valueOf(value.substring(value.length() - 2));
  validateDay();
}

相关文章