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

Java Duration类代码示例

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

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



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


示例16: parse

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

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


示例17: determineStartDate

import biweekly.util.Duration; //导入依赖的package包/类
/**
 * Determines what the alarm property's start date should be.
 * @param valarm the component that is being converted to a vCal alarm
 * property
 * @param parent the component's parent
 * @return the start date or null if it cannot be determined
 */
private static Date determineStartDate(VAlarm valarm, ICalComponent parent) {
	Trigger trigger = valarm.getTrigger();
	if (trigger == null) {
		return null;
	}

	Date triggerStart = trigger.getDate();
	if (triggerStart != null) {
		return triggerStart;
	}

	Duration triggerDuration = trigger.getDuration();
	if (triggerDuration == null) {
		return null;
	}

	if (parent == null) {
		return null;
	}

	Related related = trigger.getRelated();
	Date date = null;
	if (related == Related.START) {
		date = ValuedProperty.getValue(parent.getProperty(DateStart.class));
	} else if (related == Related.END) {
		date = ValuedProperty.getValue(parent.getProperty(DateEnd.class));
		if (date == null) {
			Date dateStart = ValuedProperty.getValue(parent.getProperty(DateStart.class));
			Duration duration = ValuedProperty.getValue(parent.getProperty(DurationProperty.class));
			if (duration != null && dateStart != null) {
				date = duration.add(dateStart);
			}
		}
	}

	return (date == null) ? null : triggerDuration.add(date);
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:45,代码来源:VAlarmScribe.java


示例18: set_value

import biweekly.util.Duration; //导入依赖的package包/类
@Test
public void set_value() {
	FreeBusy property = new FreeBusy();
	Date start = new Date();
	Duration duration = new Duration.Builder().hours(1).build();

	Period period = new Period(start, duration);
	property.getValues().add(period);
	assertEquals(Arrays.asList(period), property.getValues());
	assertNull(property.getType());

	Period period2 = new Period(start, (Date) null);
	property.getValues().add(period2);
	assertEquals(Arrays.asList(period, period2), property.getValues());
	assertNull(property.getType());

	Period period3 = new Period(start, (Duration) null);
	property.getValues().add(period3);
	assertEquals(Arrays.asList(period, period2, period3), property.getValues());
	assertNull(property.getType());

	property.setType(FreeBusyType.BUSY);
	assertEquals(Arrays.asList(period, period2, period3), property.getValues());
	assertEquals(FreeBusyType.BUSY, property.getType());

	property.setType(null);
	assertEquals(Arrays.asList(period, period2, period3), property.getValues());
	assertNull(property.getType());
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:30,代码来源:FreeBusyTest.java


示例19: validate

import biweekly.util.Duration; //导入依赖的package包/类
@Test
public void validate() {
	FreeBusy property = new FreeBusy();
	assertValidate(property).run(26);

	property = new FreeBusy();
	property.getValues().add(new Period(null, (Date) null));
	assertValidate(property).run(39, 40);

	property = new FreeBusy();
	property.getValues().add(new Period(new Date(), (Date) null));
	assertValidate(property).run(40);

	property = new FreeBusy();
	property.getValues().add(new Period(null, new Date()));
	assertValidate(property).run(39);

	property = new FreeBusy();
	property.getValues().add(new Period(new Date(), new Date()));
	assertValidate(property).run();

	property = new FreeBusy();
	property.getValues().add(new Period(null, (Duration) null));
	assertValidate(property).run(39, 40);

	property = new FreeBusy();
	property.getValues().add(new Period(new Date(), (Duration) null));
	assertValidate(property).run(40);

	property = new FreeBusy();
	property.getValues().add(new Period(null, new Duration.Builder().build()));
	assertValidate(property).run(39);

	property = new FreeBusy();
	property.getValues().add(new Period(new Date(), new Duration.Builder().build()));
	assertValidate(property).run();
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:38,代码来源:FreeBusyTest.java


示例20: copy

import biweekly.util.Duration; //导入依赖的package包/类
@Test
public void copy() {
	FreeBusy original = new FreeBusy();
	assertCopy(original).notSameDeep("getValues");

	original = new FreeBusy();
	original.getValues().add(new Period(new Date(), new Date()));
	original.getValues().add(new Period(new Date(), (Date) null));
	original.getValues().add(new Period(new Date(), new Duration.Builder().build()));
	original.getValues().add(new Period(new Date(), (Duration) null));
	assertCopy(original).notSameDeep("getValues");
}
 
开发者ID:mangstadt,项目名称:biweekly,代码行数:13,代码来源:FreeBusyTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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