本文整理汇总了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()), "");
}
示例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);
}
示例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());
}
示例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
}
示例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);
}
示例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());
}
}
示例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 "";
}
示例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);
}
示例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("");
}
示例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);
}
}
示例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();
}
示例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("");
}
示例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 "";
}
示例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);
}
示例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("");
}