当前位置: 首页>>代码示例>>Java>>正文


Java Recurrence类代码示例

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


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

示例1: buildRule

import biweekly.util.Recurrence; //导入依赖的package包/类
static String buildRule(Recurrence recurrence, Resources resources) {
    Frequency frequency = recurrence.getFrequency();
    Integer interval = recurrence.getInterval();
    switch (frequency) {
        case SECONDLY:
            return resources.getQuantityString(R.plurals.ical_recurrence_second, interval, interval);
        case MINUTELY:
            return resources.getQuantityString(R.plurals.ical_recurrence_minute, interval, interval);
        case HOURLY:
            return resources.getQuantityString(R.plurals.ical_recurrence_hourly, interval, interval);
        case DAILY:
            return resources.getQuantityString(R.plurals.ical_recurrence_daily, interval, interval);
        case WEEKLY:
            return resources.getQuantityString(R.plurals.ical_recurrence_weekly, interval, interval);
        case MONTHLY:
            return resources.getQuantityString(R.plurals.ical_recurrence_monthly, interval, interval);
        case YEARLY:
            return resources.getQuantityString(R.plurals.ical_recurrence_yearly, interval, interval);
    }
    return "";
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:22,代码来源:ICalendarUtils.java

示例2: monkey13

import biweekly.util.Recurrence; //导入依赖的package包/类
@Test
public void monkey13() {
	Recurrence rrule = new Recurrence.Builder(Frequency.DAILY)
		.workweekStarts(DayOfWeek.SUNDAY)
		.count(4)
		.interval(1)
		.byMonthDay(20, -20)
	.build();
	DateValue start = new DateValueImpl(2006, 5, 19);

	Collection<RecurrenceIterator> inclusions = Arrays.asList(
		RecurrenceIteratorFactory.createRecurrenceIterator(rrule, start, PST)
	);
	Collection<RecurrenceIterator> exclusions = Arrays.asList();
	
	CompoundIteratorImpl it = new CompoundIteratorImpl(inclusions, exclusions);
	assertIterator(Arrays.<DateValue>asList(
		new DateValueImpl(2006, 5, 20),
		new DateValueImpl(2006, 6, 11),
		new DateValueImpl(2006, 6, 20),
		new DateValueImpl(2006, 7, 12)
	), it);
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:24,代码来源:CompoundIteratorImplTest.java

示例3: monkey9

import biweekly.util.Recurrence; //导入依赖的package包/类
@Test
public void monkey9() {
	// another libical crasher
	Recurrence rrule = new Recurrence.Builder(Frequency.MONTHLY)
		.workweekStarts(DayOfWeek.SUNDAY)
		.interval(1)
		.byWeekNo(5,-5)
		.bySecond(0)
	.build();
	DateValue start = new DateValueImpl(2006, 4, 27);

	Collection<RecurrenceIterator> inclusions = Arrays.asList(
		RecurrenceIteratorFactory.createRecurrenceIterator(rrule, start, PST)
	);
	Collection<RecurrenceIterator> exclusions = Arrays.asList();
	
	CompoundIteratorImpl it = new CompoundIteratorImpl(inclusions, exclusions);
	assertIterator(Arrays.<DateValue>asList(
		//all the 27ths of the month.	BYWEEKNO ignores since not yearly
		new DateValueImpl(2006, 4, 27),
		new DateValueImpl(2006, 5, 27),
		new DateValueImpl(2006, 6, 27),
		new DateValueImpl(2006, 7, 27),
		new DateValueImpl(2006, 8, 27)
	), it, false);
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:27,代码来源:CompoundIteratorImplTest.java

示例4: americaNewYorkWithoutDaylight

import biweekly.util.Recurrence; //导入依赖的package包/类
private TimezoneInfo americaNewYorkWithoutDaylight() {
	VTimezone timezone = new VTimezone("id");
	{

		StandardTime standard = new StandardTime();
		standard.setDateStart(new DateTimeComponents(2007, 11, 4, 2, 0, 0, false));
		standard.setTimezoneOffsetFrom(new UtcOffset(false, 4, 0));
		standard.setTimezoneOffsetTo(new UtcOffset(false, 5, 0));
		standard.addTimezoneName("EST");
		//@formatter:off
		standard.setRecurrenceRule(new Recurrence.Builder
		(Frequency.YEARLY)
		.byMonth(11)
		.byDay(1, DayOfWeek.SUNDAY)
		.build());
		//@formatter:on
		timezone.addStandardTime(standard);
	}

	ICalTimeZone icalTz = new ICalTimeZone(timezone);

	TimezoneInfo tzinfo = new TimezoneInfo();
	tzinfo.setDefaultTimezone(new TimezoneAssignment(icalTz, timezone));
	return tzinfo;
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:26,代码来源:ICalWriterTest.java

示例5: firstWeekdayOfFirstWeekOfYear

import biweekly.util.Recurrence; //导入依赖的package包/类
/**
 * Find the first weekday of the first week of the year.
 * The first week of the year may be partial, and the first week is considered
 * to be the first one with at least four days.
 */
@Test
public void firstWeekdayOfFirstWeekOfYear() {
	Recurrence recur = new Recurrence.Builder(Frequency.YEARLY)
		.byWeekNo(1)
		.byDay(DayOfWeek.MONDAY, DayOfWeek.TUESDAY, DayOfWeek.WEDNESDAY, DayOfWeek.THURSDAY, DayOfWeek.FRIDAY)
		.bySetPos(1)
	.build();
	DateValue start = new DateValueImpl(1999, 1, 1);
	DateValue[] expected = {
		new DateValueImpl(1999, 1, 4),
		new DateValueImpl(2000, 1, 3),
		new DateValueImpl(2001, 1, 1),
		new DateValueImpl(2002, 1, 1)
	};

	run(recur, start, expected);
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:23,代码来源:RRuleIteratorImplTest.java

示例6: _writeXml

import biweekly.util.Recurrence; //导入依赖的package包/类
@Override
protected void _writeXml(T property, XCalElement element, WriteContext context) {
	XCalElement recurElement = element.append(dataType(property, null));

	Recurrence recur = property.getValue();
	if (recur == null) {
		return;
	}

	ListMultimap<String, Object> components = buildComponents(property, context, true);
	for (Map.Entry<String, List<Object>> component : components) {
		String name = component.getKey().toLowerCase();
		for (Object value : component.getValue()) {
			recurElement.append(name, value.toString());
		}
	}
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:18,代码来源:RecurrencePropertyScribe.java

示例7: monkey14

import biweekly.util.Recurrence; //导入依赖的package包/类
@Test
public void monkey14() {
	Recurrence rrule = new Recurrence.Builder(Frequency.YEARLY)
		.byDay(DayOfWeek.THURSDAY)
	.build();
	DateValue start = new DateValueImpl(2006, 5, 6);

	Collection<RecurrenceIterator> inclusions = Arrays.asList(
		RecurrenceIteratorFactory.createRecurrenceIterator(rrule, start, PST)
	);
	Collection<RecurrenceIterator> exclusions = Arrays.asList();
	
	CompoundIteratorImpl it = new CompoundIteratorImpl(inclusions, exclusions);
	assertIterator(Arrays.<DateValue>asList(
		new DateValueImpl(2006, 5, 11),
		new DateValueImpl(2006, 5, 18),
		new DateValueImpl(2006, 5, 25),
		new DateValueImpl(2006, 6, 1)
	), it, false);
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:21,代码来源:CompoundIteratorImplTest.java

示例8: hourlyWithBydayAcrossMonthBoundary

import biweekly.util.Recurrence; //导入依赖的package包/类
@Test
public void hourlyWithBydayAcrossMonthBoundary() {
	Recurrence recur = new Recurrence.Builder(Frequency.HOURLY)
		.interval(6)
		.byDay(DayOfWeek.TUESDAY, DayOfWeek.THURSDAY)
		.count(5)
	.build();
	DateValue start = new DateTimeValueImpl(2011, 8, 31, 12, 30, 0);
	DateValue[] expected = {
		new DateTimeValueImpl(2011, 9, 1, 0, 30, 0),
		new DateTimeValueImpl(2011, 9, 1, 6, 30, 0),
		new DateTimeValueImpl(2011, 9, 1, 12, 30, 0),
		new DateTimeValueImpl(2011, 9, 1, 18, 30, 0),
		new DateTimeValueImpl(2011, 9, 6, 0, 30, 0)
	};

	run(recur, start, expected);
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:19,代码来源:RRuleIteratorImplTest.java

示例9: getDateIterator

import biweekly.util.Recurrence; //导入依赖的package包/类
@Test
public void getDateIterator() {
	Recurrence recur = new Recurrence.Builder(Frequency.DAILY).count(5).build();
	RecurrenceProperty property = new RecurrenceProperty(recur);
	Date start = date("2014-11-22 10:00:00");

	//@formatter:off
	List<Date> expected = Arrays.asList(
		date("2014-11-22 10:00:00"),
		date("2014-11-23 10:00:00"),
		date("2014-11-24 10:00:00"),
		date("2014-11-25 10:00:00"),
		date("2014-11-26 10:00:00")
	);
	//@formatter:on

	DateIterator it = property.getDateIterator(start, TimeZone.getDefault());
	assertIterator(expected, it);
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:20,代码来源:RecurrencePropertyTest.java

示例10: weirdByMonth

import biweekly.util.Recurrence; //导入依赖的package包/类
@Test
public void weirdByMonth() {
	Recurrence recur = new Recurrence.Builder(Frequency.YEARLY)
		.interval(1)
		.byMonth(2, 7, 4, 9, 9, 6, 11, 1)
	.build();
	DateValue start = new DateValueImpl(1949, 3, 20);
	DateValue[] expected = {
			new DateValueImpl(1949, 4, 20),
			new DateValueImpl(1949, 6, 20),
			new DateValueImpl(1949, 7, 20),
			new DateValueImpl(1949, 9, 20),
			new DateValueImpl(1949, 11, 20),
			new DateValueImpl(1950, 1, 20),
			new DateValueImpl(1950, 2, 20),
			new DateValueImpl(1950, 4, 20),
			new DateValueImpl(1950, 6, 20),
			new DateValueImpl(1950, 7, 20),
			new DateValueImpl(1950, 9, 20),
			new DateValueImpl(1950, 11, 20)
	};

	run(recur, start, expected);
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:25,代码来源:RRuleIteratorImplTest.java

示例11: run

import biweekly.util.Recurrence; //导入依赖的package包/类
/**
 * <p>
 * Asserts the dates in a given recurrence.
 * </p>
 * <p>
 * This method automatically determines if the the given recurrence is
 * non-terminating. If it is non-terminating, then this method will stop
 * iterating once it generates the same number of items that there are in the
 * list of expected values.
 * </p>
 * @param recur the recurrence
 * @param start the start date
 * @param tz the timezone of the start date
 * @param advanceTo the date for the iterator to advance to (in UTC)
 * @param expected the expected dates in the recurrence
 */
private static void run(Recurrence recur, DateValue start, TimeZone tz, DateValue advanceTo, DateValue[] expected) {		
	RecurrenceIterator it = RecurrenceIteratorFactory.createRecurrenceIterator(recur, start, tz);
	if (advanceTo != null){
		it.advanceTo(advanceTo);
	}
	
	boolean iteratorIsTerminating = (recur.getUntil() != null || recur.getCount() != null);
	
	assertIterator(Arrays.asList(expected), it, iteratorIsTerminating);
	
	/*
	 * Advancing to the start date should yield the same result.
	 */
	if (advanceTo == null){
		it = RecurrenceIteratorFactory.createRecurrenceIterator(recur, start, tz);
		it.advanceTo(start);
		assertIterator(Arrays.asList(expected), it, iteratorIsTerminating);
	}
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:36,代码来源:RRuleIteratorImplTest.java

示例12: monkey3

import biweekly.util.Recurrence; //导入依赖的package包/类
@Test
public void monkey3() {
	Recurrence rrule = new Recurrence.Builder(Frequency.YEARLY)
		.workweekStarts(DayOfWeek.SUNDAY)
		.interval(1)
		.bySecond(14)
	.build();
	DateValue start = new DateTimeValueImpl(2006, 5, 9, 3, 45, 40);

	Collection<RecurrenceIterator> inclusions = Arrays.asList(
		RecurrenceIteratorFactory.createRecurrenceIterator(rrule, start, PST)
	);
	Collection<RecurrenceIterator> exclusions = Arrays.asList();
	
	CompoundIteratorImpl it = new CompoundIteratorImpl(inclusions, exclusions);
	assertIterator(Arrays.<DateValue>asList(
		new DateTimeValueImpl(2007, 5, 9, 10, 45, 14),
		new DateTimeValueImpl(2008, 5, 9, 10, 45, 14),
		new DateTimeValueImpl(2009, 5, 9, 10, 45, 14)
	), it, false);
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:22,代码来源:CompoundIteratorImplTest.java

示例13: excludedStart

import biweekly.util.Recurrence; //导入依赖的package包/类
@Test
public void excludedStart() {
	Recurrence rrule = new Recurrence.Builder(Frequency.YEARLY)
		.until(date("2007-04-14", PST))
		.interval(1)
		.byDay(3, DayOfWeek.SUNDAY)
		.byMonth(4)
	.build();
	List<DateValue> exdates = Arrays.<DateValue>asList(
		new DateValueImpl(2006, 4, 16)
	);
	DateValue start = new DateValueImpl(2006, 4, 16);

	Collection<RecurrenceIterator> inclusions = Arrays.asList(
		RecurrenceIteratorFactory.createRecurrenceIterator(rrule, start, PST)
	);
	Collection<RecurrenceIterator> exclusions = Arrays.asList(
		RecurrenceIteratorFactory.createRecurrenceIterator(exdates)
	);
	
	CompoundIteratorImpl it = new CompoundIteratorImpl(inclusions, exclusions);
	assertIterator(Arrays.<DateValue>asList(
	), it);
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:25,代码来源:CompoundIteratorImplTest.java

示例14: check

import biweekly.util.Recurrence; //导入依赖的package包/类
public void check(RecurrenceProperty property, ParseContext context) {
	Recurrence recur = property.getValue();
	assertNull(recur.getFrequency());
	assertNull(recur.getCount());
	assertNull(recur.getInterval());
	assertNull(recur.getUntil());
	assertEquals(Arrays.asList(), recur.getByMinute());
	assertEquals(Arrays.asList(), recur.getByHour());
	assertEquals(Arrays.asList(), recur.getByDay());
	assertEquals(Arrays.asList(), recur.getByMonthDay());
	assertEquals(Arrays.asList(), recur.getByYearDay());
	assertEquals(Arrays.asList(), recur.getByMonth());
	assertEquals(Arrays.asList(), recur.getBySetPos());
	assertEquals(Arrays.asList(), recur.getByWeekNo());
	assertNull(recur.getWorkweekStarts());
	assertTrue(recur.getXRules().isEmpty());
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:18,代码来源:RecurrencePropertyScribeTest.java

示例15: monkey10_2

import biweekly.util.Recurrence; //导入依赖的package包/类
@Test
public void monkey10_2() {
	// another libical hanger
	Recurrence rrule = new Recurrence.Builder(Frequency.YEARLY)
		.byYearDay(1)
		.byMonthDay(2)
	.build();
	DateValue start = new DateValueImpl(2006, 4, 27);

	Collection<RecurrenceIterator> inclusions = Arrays.asList(
		RecurrenceIteratorFactory.createRecurrenceIterator(rrule, start, PST)
	);
	Collection<RecurrenceIterator> exclusions = Arrays.asList();
	
	CompoundIteratorImpl it = new CompoundIteratorImpl(inclusions, exclusions);
	assertIterator(Arrays.<DateValue>asList(
		//empty
	), it);
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:20,代码来源:CompoundIteratorImplTest.java


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