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


Java Duration类代码示例

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


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

示例1: _writeXml

import biweekly.util.Duration; //导入依赖的package包/类
@Override
protected void _writeXml(Trigger property, XCalElement element, WriteContext context) {
	Duration duration = property.getDuration();
	if (duration != null) {
		element.append(ICalDataType.DURATION, duration.toString());
		return;
	}

	Date date = property.getDate();
	if (date != null) {
		String dateStr = date(date, property, context).extended(true).write();
		element.append(ICalDataType.DATE_TIME, dateStr);
		return;
	}

	element.append(defaultDataType(context.getVersion()), "");
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:18,代码来源:TriggerScribe.java

示例2: _writeText

import biweekly.util.Duration; //导入依赖的package包/类
@Override
protected String _writeText(T property, WriteContext context) {
	List<String> values = new ArrayList<String>();

	Date start = property.getStart();
	String value = date(start, property, context).extended(false).write();
	values.add(value);

	Duration snooze = property.getSnooze();
	value = (snooze == null) ? "" : snooze.toString();
	values.add(value);

	Integer repeat = property.getRepeat();
	value = (repeat == null) ? "" : repeat.toString();
	values.add(value);

	List<String> dataValues = writeData(property);
	values.addAll(dataValues);

	boolean escapeCommas = (context.getVersion() != ICalVersion.V1_0);
	return VObjectPropertyValues.writeSemiStructured(values, escapeCommas, true);
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:23,代码来源:VCalAlarmPropertyScribe.java

示例3: constructors

import biweekly.util.Duration; //导入依赖的package包/类
@Test
public void constructors() throws Exception {
	Trigger property = new Trigger((Date) null);
	assertNull(property.getDate());
	assertNull(property.getDuration());
	assertNull(property.getRelated());

	Date date = new Date();
	property = new Trigger(date);
	assertEquals(date, property.getDate());
	assertNull(property.getDuration());
	assertNull(property.getRelated());

	Duration duration = new Duration.Builder().hours(1).build();
	property = new Trigger(duration, Related.START);
	assertNull(property.getDate());
	assertEquals(duration, property.getDuration());
	assertEquals(Related.START, property.getRelated());
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:20,代码来源:TriggerTest.java

示例4: equals

import biweekly.util.Duration; //导入依赖的package包/类
@Test
public void equals() {
	//@formatter:off
	assertNothingIsEqual(
		new Trigger((Date)null),
		new Trigger(date("2016-01-21")),
		new Trigger(date("2016-01-22")),
		new Trigger(new Duration.Builder().hours(1).build(), null),
		new Trigger(new Duration.Builder().hours(1).build(), Related.START),
		new Trigger(new Duration.Builder().hours(1).build(), Related.END),
		new Trigger(new Duration.Builder().hours(2).build(), Related.START)
	);

	assertEqualsMethod(Trigger.class, new Date())
	.constructor(new Class<?>[]{Date.class}, (Date)null).test()
	.constructor(new Date()).test()
	.constructor(new Duration.Builder().hours(1).build(), Related.START).test();
	//@formatter:on
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:20,代码来源:TriggerTest.java

示例5: validate_cardinality_optional

import biweekly.util.Duration; //导入依赖的package包/类
@Test
public void validate_cardinality_optional() {
	ICalendar ical = new ICalendar();
	ical.addExperimentalComponent("X-SUPPRESS-NO-COMPONENT-WARNING");
	assertValidate(ical).run();

	ical.addProperty(new Uid("value"));
	ical.addProperty(new LastModified(new Date()));
	ical.addProperty(new Url(""));
	ical.addProperty(new RefreshInterval(new Duration.Builder().hours(1).build()));
	ical.addProperty(new Color("value"));
	ical.addProperty(new Source("value"));
	assertValidate(ical).run();

	ical.addProperty(new Uid("value"));
	ical.addProperty(new LastModified(new Date()));
	ical.addProperty(new Url(""));
	ical.addProperty(new RefreshInterval(new Duration.Builder().hours(1).build()));
	ical.addProperty(new Color("value"));
	ical.addProperty(new Source("value"));
	assertValidate(ical).run(3, 3, 3, 3, 3, 3);
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:23,代码来源:ICalendarTest.java

示例6: checkForDataModelConversions_snooze

import biweekly.util.Duration; //导入依赖的package包/类
@Test
public void checkForDataModelConversions_snooze() {
	Action action = Action.audio();
	Duration snooze = new Duration.Builder().minutes(10).build();

	VAlarm alarm = new VAlarm(action, null);
	alarm.setDuration(snooze);
	try {
		scribe.checkForDataModelConversions(alarm, null, V1_0);
	} catch (DataModelConversionException e) {
		AudioAlarm expected = new AudioAlarm();
		expected.setSnooze(snooze);
		assertNull(e.getOriginalProperty());
		assertEquals(Arrays.asList(expected), e.getProperties());
		assertEquals(Arrays.asList(), e.getComponents());
	}
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:18,代码来源:VAlarmScribeTest.java

示例7: _writeText

import biweekly.util.Duration; //导入依赖的package包/类
@Override
protected String _writeText(RefreshInterval property, WriteContext context) {
	Duration duration = property.getValue();
	if (duration != null) {
		return duration.toString();
	}

	return "";
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:10,代码来源:RefreshIntervalScribe.java

示例8: _writeXml

import biweekly.util.Duration; //导入依赖的package包/类
@Override
protected void _writeXml(RefreshInterval property, XCalElement element, WriteContext context) {
	String durationStr = null;

	Duration duration = property.getValue();
	if (duration != null) {
		durationStr = duration.toString();
	}

	element.append(dataType(property, null), durationStr);
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:12,代码来源:RefreshIntervalScribe.java

示例9: _writeJson

import biweekly.util.Duration; //导入依赖的package包/类
@Override
protected JCalValue _writeJson(RefreshInterval property, WriteContext context) {
	Duration value = property.getValue();
	if (value != null) {
		return JCalValue.single(value.toString());
	}

	return JCalValue.single("");
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:10,代码来源:RefreshIntervalScribe.java

示例10: parse

import biweekly.util.Duration; //导入依赖的package包/类
private RefreshInterval parse(String value) {
	if (value == null) {
		return new RefreshInterval((Duration) null);
	}

	try {
		Duration duration = Duration.parse(value);
		return new RefreshInterval(duration);
	} catch (IllegalArgumentException e) {
		throw new CannotParseException(18);
	}
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:13,代码来源:RefreshIntervalScribe.java

示例11: _writeText

import biweekly.util.Duration; //导入依赖的package包/类
@Override
protected String _writeText(Trigger property, WriteContext context) {
	Duration duration = property.getDuration();
	if (duration != null) {
		return duration.toString();
	}

	Date date = property.getDate();
	return date(date, property, context).extended(false).write();
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:11,代码来源:TriggerScribe.java

示例12: _writeJson

import biweekly.util.Duration; //导入依赖的package包/类
@Override
protected JCalValue _writeJson(Trigger property, WriteContext context) {
	Duration duration = property.getDuration();
	if (duration != null) {
		return JCalValue.single(duration.toString());
	}

	Date date = property.getDate();
	if (date != null) {
		String dateStr = date(date, property, context).extended(true).write();
		return JCalValue.single(dateStr);
	}

	return JCalValue.single("");
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:16,代码来源:TriggerScribe.java

示例13: _writeText

import biweekly.util.Duration; //导入依赖的package包/类
@Override
protected String _writeText(DurationProperty property, WriteContext context) {
	Duration duration = property.getValue();
	if (duration != null) {
		return duration.toString();
	}

	return "";
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:10,代码来源:DurationPropertyScribe.java

示例14: _writeXml

import biweekly.util.Duration; //导入依赖的package包/类
@Override
protected void _writeXml(DurationProperty property, XCalElement element, WriteContext context) {
	String durationStr = null;

	Duration duration = property.getValue();
	if (duration != null) {
		durationStr = duration.toString();
	}

	element.append(dataType(property, null), durationStr);
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:12,代码来源:DurationPropertyScribe.java

示例15: _writeJson

import biweekly.util.Duration; //导入依赖的package包/类
@Override
protected JCalValue _writeJson(DurationProperty property, WriteContext context) {
	Duration value = property.getValue();
	if (value != null) {
		return JCalValue.single(value.toString());
	}

	return JCalValue.single("");
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:10,代码来源:DurationPropertyScribe.java


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