• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RRule类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.ical.values.RRule的典型用法代码示例。如果您正苦于以下问题:Java RRule类的具体用法?Java RRule怎么用?Java RRule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RRule类属于com.google.ical.values包,在下文中一共展示了RRule类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: runRecurrenceIteratorTest

import com.google.ical.values.RRule; //导入依赖的package包/类
private void runRecurrenceIteratorTest(
        String rruleText, DateValue dtStart, int limit, String golden,
        DateValue advanceTo, TimeZone tz)
        throws Exception {
    RecurrenceIterator ri = RecurrenceIteratorFactory.createRecurrenceIterator(
            new RRule(rruleText), dtStart, tz);
    if (null != advanceTo) {
        ri.advanceTo(advanceTo);
    }
    StringBuilder sb = new StringBuilder();
    int k = 0, n = limit;
    while (ri.hasNext() && --n >= 0) {
        if (k++ != 0) {
            sb.append(',');
        }
        sb.append(ri.next());
    }
    if (n < 0) {
        sb.append(",...");
    }
    assertEquals(golden, sb.toString());

    if (null == advanceTo) {
        runRecurrenceIteratorTest(rruleText, dtStart, limit, golden, dtStart, tz);
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:27,代码来源:RRuleIteratorImplTest.java


示例2: createIterator

import com.google.ical.values.RRule; //导入依赖的package包/类
public DateRecurrenceIterator createIterator(Date now) {
    RRule rrule = createRRule();
    try {
        Log.d("RRULE", "Creating iterator for "+rrule.toIcal());
        if (now.before(startDate.getTime())) {
            now = startDate.getTime();
        }
        Calendar c = Calendar.getInstance();
        c.setTime(startDate.getTime());
        //c.set(Calendar.HOUR_OF_DAY, startDate.get(Calendar.HOUR_OF_DAY));
        //c.set(Calendar.MINUTE, startDate.get(Calendar.MINUTE));
        //c.set(Calendar.SECOND, startDate.get(Calendar.SECOND));
        c.set(Calendar.MILLISECOND, 0);
        return DateRecurrenceIterator.create(rrule, now, c.getTime());
    } catch (ParseException e) {
        Log.w("RRULE", "Unable to create iterator for "+rrule.toIcal());
        return DateRecurrenceIterator.empty();
    }
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:20,代码来源:Recurrence.java


示例3: createRRule

import com.google.ical.values.RRule; //导入依赖的package包/类
private RRule createRRule() {
	if (pattern.frequency == RecurrenceFrequency.GEEKY) {
		try {
			HashMap<String, String> map = RecurrenceViewFactory.parseState(pattern.params);
			String rrule = map.get(RecurrenceViewFactory.P_INTERVAL);
			return new RRule("RRULE:"+rrule.toUpperCase());
		} catch (ParseException e) {
			throw new IllegalArgumentException(pattern.params);
		}
	} else {
		RRule r = new RRule();
		pattern.updateRRule(r);
		period.updateRRule(r, startDate);
		return r;
	}
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:17,代码来源:Recurrence.java


示例4: computeNextDueDate

import com.google.ical.values.RRule; //导入依赖的package包/类
/** Compute next due date */
public static long computeNextDueDate(Task task, String recurrence, boolean repeatAfterCompletion) throws ParseException {
    RRule rrule = initRRule(recurrence);

    // initialize startDateAsDV
    DateTime original = setUpStartDate(task, repeatAfterCompletion, rrule.getFreq());
    DateValue startDateAsDV = setUpStartDateAsDV(task, original);

    if(rrule.getFreq() == Frequency.HOURLY || rrule.getFreq() == Frequency.MINUTELY) {
        return handleSubdayRepeat(original, rrule);
    } else if(rrule.getFreq() == Frequency.WEEKLY && rrule.getByDay().size() > 0 && repeatAfterCompletion) {
        return handleWeeklyRepeatAfterComplete(rrule, original, task.hasDueTime());
    } else if (rrule.getFreq() == Frequency.MONTHLY) {
        return handleMonthlyRepeat(original, startDateAsDV, task.hasDueTime(), rrule);
    } else {
        return invokeRecurrence(rrule, original, startDateAsDV);
    }
}
 
开发者ID:andyCano,项目名称:TaskApp,代码行数:19,代码来源:RepeatTaskCompleteListener.java


示例5: handleWeeklyRepeatAfterComplete

import com.google.ical.values.RRule; //导入依赖的package包/类
private static long handleWeeklyRepeatAfterComplete(RRule rrule, DateTime original,
        boolean hasDueTime) {
    List<WeekdayNum> byDay = rrule.getByDay();
    long newDate = original.getMillis();
    newDate += DateUtilities.ONE_WEEK * (rrule.getInterval() - 1);
    DateTime date = new DateTime(newDate);

    Collections.sort(byDay, weekdayCompare);
    WeekdayNum next = findNextWeekday(byDay, date);

    do {
        date = date.plusDays(1);
    } while (date.getDayOfWeek() != next.wday.javaDayNum);

    long time = date.getMillis();
    if(hasDueTime) {
        return Task.createDueDate(Task.URGENCY_SPECIFIC_DAY_TIME, time);
    } else {
        return Task.createDueDate(Task.URGENCY_SPECIFIC_DAY, time);
    }
}
 
开发者ID:andyCano,项目名称:TaskApp,代码行数:22,代码来源:RepeatTaskCompleteListener.java


示例6: handleMonthlyRepeat

import com.google.ical.values.RRule; //导入依赖的package包/类
private static long handleMonthlyRepeat(DateTime original, DateValue startDateAsDV, boolean hasDueTime, RRule rrule) {
    if (original.isLastDayOfMonth()) {
        int interval = rrule.getInterval();

        DateTime newDateTime = original.plusMonths(interval);
        long time = newDateTime
                .withDayOfMonth(newDateTime.getNumberOfDaysInMonth())
                .getMillis();
        if (hasDueTime) {
            return Task.createDueDate(Task.URGENCY_SPECIFIC_DAY_TIME, time);
        } else {
            return Task.createDueDate(Task.URGENCY_SPECIFIC_DAY, time);
        }
    } else {
        return invokeRecurrence(rrule, original, startDateAsDV);
    }
}
 
开发者ID:andyCano,项目名称:TaskApp,代码行数:18,代码来源:RepeatTaskCompleteListener.java


示例7: invokeRecurrence

import com.google.ical.values.RRule; //导入依赖的package包/类
private static long invokeRecurrence(RRule rrule, DateTime original, DateValue startDateAsDV) {
    long newDueDate = -1;
    RecurrenceIterator iterator = RecurrenceIteratorFactory.createRecurrenceIterator(rrule,
            startDateAsDV, TimeZone.getDefault());
    DateValue nextDate;

    for(int i = 0; i < 10; i++) { // ten tries then we give up
        if(!iterator.hasNext()) {
            return -1;
        }
        nextDate = iterator.next();

        if(nextDate.compareTo(startDateAsDV) == 0) {
            continue;
        }

        newDueDate = buildNewDueDate(original, nextDate);

        // detect if we finished
        if(newDueDate > original.getMillis()) {
            break;
        }
    }
    return newDueDate;
}
 
开发者ID:andyCano,项目名称:TaskApp,代码行数:26,代码来源:RepeatTaskCompleteListener.java


示例8: updateRRule

import com.google.ical.values.RRule; //导入依赖的package包/类
public void updateRRule(RRule r, Calendar startDate) {
	HashMap<String, String> state = RecurrenceViewFactory.parseState(params);
	switch (until) {
	case EXACTLY_TIMES:
		int count = Integer.parseInt(state.get(RecurrenceViewFactory.P_COUNT));
		r.setCount(count);
		break;
	case STOPS_ON_DATE:
		Calendar c = Calendar.getInstance();
		String stopsOnDate = state.get(RecurrenceViewFactory.P_DATE);
		try {
			c.setTime(DateUtils.FORMAT_DATE_RFC_2445.parse(stopsOnDate));
			c.set(Calendar.HOUR_OF_DAY, startDate.get(Calendar.HOUR_OF_DAY));
			c.set(Calendar.MINUTE, startDate.get(Calendar.MINUTE));
			c.set(Calendar.SECOND, startDate.get(Calendar.SECOND));
			c.set(Calendar.MILLISECOND, 0);
		} catch (ParseException e) {
			throw new IllegalArgumentException(params);
		}
		r.setUntil(dateToDateValue(c.getTime()));
		break;
	}
}
 
开发者ID:emmanuel-florent,项目名称:flowzr-android-black,代码行数:24,代码来源:RecurrencePeriod.java


示例9: set

import com.google.ical.values.RRule; //导入依赖的package包/类
@Override
public void set(String newValue) {
    try {
        if (newValue != null) {
            new RRule(newValue);
        }
        super.set(newValue);
    } catch (ParseException e) {
        e.printStackTrace();
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:12,代码来源:RecurrenceView.java


示例10: testFrequencyLimits

import com.google.ical.values.RRule; //导入依赖的package包/类
public void testFrequencyLimits() throws Exception {
    RecurrenceIteratorFactory.createRecurrenceIterator(
            new RRule(
                    "RRULE:FREQ=SECONDLY;BYSECOND=0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,"
                            + "15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,"
                            + "30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,"
                            + "45,46,47,48,49,50,51,52,53,54,55,56,57,58,59"),
            IcalParseUtil.parseDateValue("20000101"), TimeUtils.utcTimezone());
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:10,代码来源:RRuleIteratorImplTest.java


示例11: testNextCalledWithoutHasNext

import com.google.ical.values.RRule; //导入依赖的package包/类
public void testNextCalledWithoutHasNext() throws Exception {
    RecurrenceIterator riter =
            RecurrenceIteratorFactory.createRecurrenceIterator(
                    new RRule("RRULE:FREQ=DAILY"),
                    IcalParseUtil.parseDateValue("20000101"), TimeUtils.utcTimezone());
    assertEquals(IcalParseUtil.parseDateValue("20000101"), riter.next());
    assertEquals(IcalParseUtil.parseDateValue("20000102"), riter.next());
    assertEquals(IcalParseUtil.parseDateValue("20000103"), riter.next());
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:10,代码来源:RRuleIteratorImplTest.java


示例12: testNoInstancesGenerated

import com.google.ical.values.RRule; //导入依赖的package包/类
public void testNoInstancesGenerated() throws Exception {
    RecurrenceIterator riter =
            RecurrenceIteratorFactory.createRecurrenceIterator(
                    new RRule("RRULE:FREQ=DAILY;UNTIL=19990101"),
                    IcalParseUtil.parseDateValue("20000101"), TimeUtils.utcTimezone());
    assertTrue(!riter.hasNext());

    assertNull(riter.next());
    assertNull(riter.next());
    assertNull(riter.next());
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:12,代码来源:RRuleIteratorImplTest.java


示例13: testNoInstancesGenerated2

import com.google.ical.values.RRule; //导入依赖的package包/类
public void testNoInstancesGenerated2() throws Exception {
    RecurrenceIterator riter =
            RecurrenceIteratorFactory.createRecurrenceIterator(
                    new RRule("RRULE:FREQ=YEARLY;BYMONTH=2;BYMONTHDAY=30"),
                    IcalParseUtil.parseDateValue("20000101"), TimeUtils.utcTimezone());
    assertTrue(!riter.hasNext());
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:8,代码来源:RRuleIteratorImplTest.java


示例14: testNoInstancesGenerated3

import com.google.ical.values.RRule; //导入依赖的package包/类
public void testNoInstancesGenerated3() throws Exception {
    RecurrenceIterator riter =
            RecurrenceIteratorFactory.createRecurrenceIterator(
                    new RRule("RRULE:FREQ=YEARLY;INTERVAL=4;BYYEARDAY=366"),
                    IcalParseUtil.parseDateValue("20010101"), TimeUtils.utcTimezone());
    assertTrue(!riter.hasNext());
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:8,代码来源:RRuleIteratorImplTest.java


示例15: runOne

import com.google.ical.values.RRule; //导入依赖的package包/类
void runOne() throws Exception {
    for (String rdata : RECURRENCE_RULES) {
        RRule rrule = new RRule(rdata);
        RecurrenceIterator iter =
                RecurrenceIteratorFactory.createRecurrenceIterator(
                        rrule, DT_START, TimeUtils.utcTimezone());
        iter.advanceTo(T0);
        for (int k = 20; iter.hasNext() && --k >= 0; ) {
            iter.next();
        }
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:13,代码来源:StressTest.java


示例16: testNoExceptionsThrownOnWelformedRrules

import com.google.ical.values.RRule; //导入依赖的package包/类
public void testNoExceptionsThrownOnWelformedRrules() throws Throwable {
    final int nRuns = 1000;
    final int countLimit = 2000;
    int totalGened = 0;  // total number of instances generated.
    Histogram histogram = new Histogram(nRuns);
    for (int i = 0; i < nRuns; ++i) {
        System.err.print("<");
        DumpStackTask task = dumpStackIfRunsTooLong();
        boolean timed = rnd.nextBoolean();
        RRule rrule = monkeySeeRRule(timed, true);
        task.rrule = rrule;
        DateValue dtStart = monkeySeeDateValue(maybeNot(timed));
        task.dtStart = dtStart;
        try {
            RecurrenceIterator it = RecurrenceIteratorFactory
                    .createRecurrenceIterator(rrule, dtStart, PST);
            int tries = countLimit;
            long t0 = System.nanoTime();
            while (it.hasNext() && --tries >= 0) {
                it.next();
            }
            long dt = System.nanoTime() - t0;
            histogram.addSample(dt / 1000);  // nanoseconds -> microseconds
            totalGened += countLimit - tries;
        } catch (Throwable th) {
            task.cancel();
            System.err.println("\n" + rrule.toIcal() + " / " + dtStart);
            throw th;
        }
        task.cancel();
        System.err.print(">");
    }
    // to see this, run the test with --nooutputredirect
    histogram.dump(16, "microseconds");
    System.out.println("totalGenerated=" + totalGened);
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:37,代码来源:MonkeyKeyboardTest.java


示例17: main

import com.google.ical.values.RRule; //导入依赖的package包/类
/** generate a batch of 10000 random recurrence rules. */
public static void main(String[] args) throws Exception {
    MonkeyKeyboardTest mkt = new MonkeyKeyboardTest();
    mkt.setUp();
    for (int i = 0; i < 10000; ++i) {
        boolean timed = mkt.rnd.nextBoolean();
        RRule rrule = mkt.monkeySeeRRule(timed, false);
        DateValue dtstart = mkt.monkeySeeDateValue(timed);
        System.out.println("BEGIN:VEVENT\nDTSTART:" + dtstart
                + "\n" + rrule.toIcal() + "\nEND:VEVENT\n");
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:13,代码来源:MonkeyKeyboardTest.java


示例18: create

import com.google.ical.values.RRule; //导入依赖的package包/类
public static DateRecurrenceIterator create(RRule rrule, Date nowDate, Date startDate) throws ParseException {
       RecurrenceIterator ri = RecurrenceIteratorFactory.createRecurrenceIterator(rrule,
               dateToDateValue(startDate), TimeUtils.utcTimezone());
       Date date = null;
       while (ri.hasNext() && (date = dateValueToDate(ri.next())).before(nowDate));
       //ri.advanceTo(dateToDateValue(nowDate));
       DateRecurrenceIterator iterator = new DateRecurrenceIterator(ri);
       iterator.firstDate = date;
       return iterator;
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:11,代码来源:DateRecurrenceIterator.java


示例19: initRRule

import com.google.ical.values.RRule; //导入依赖的package包/类
/** Initialize RRule instance */
private static RRule initRRule(String recurrence) throws ParseException {
    RRule rrule = new RRule(recurrence);

    // handle the iCalendar "byDay" field differently depending on if
    // we are weekly or otherwise
    if(rrule.getFreq() != Frequency.WEEKLY) {
        rrule.setByDay(Collections.EMPTY_LIST);
    }

    return rrule;
}
 
开发者ID:andyCano,项目名称:TaskApp,代码行数:13,代码来源:RepeatTaskCompleteListener.java


示例20: handleSubdayRepeat

import com.google.ical.values.RRule; //导入依赖的package包/类
static long handleSubdayRepeat(DateTime startDate, RRule rrule) {
    long millis;
    switch(rrule.getFreq()) {
    case HOURLY:
        millis = DateUtilities.ONE_HOUR;
        break;
    case MINUTELY:
        millis = DateUtilities.ONE_MINUTE;
        break;
    default:
        throw new RuntimeException("Error handing subday repeat: " + rrule.getFreq()); //$NON-NLS-1$
    }
    long newDueDate = startDate.getMillis() + millis * rrule.getInterval();
    return Task.createDueDate(Task.URGENCY_SPECIFIC_DAY_TIME, newDueDate);
}
 
开发者ID:andyCano,项目名称:TaskApp,代码行数:16,代码来源:RepeatTaskCompleteListener.java



注:本文中的com.google.ical.values.RRule类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XeSource类代码示例发布时间:2022-05-23
下一篇:
Java AsyncClientHttpRequest类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap