本文整理汇总了Java中net.fortuna.ical4j.model.property.Duration类的典型用法代码示例。如果您正苦于以下问题:Java Duration类的具体用法?Java Duration怎么用?Java Duration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Duration类属于net.fortuna.ical4j.model.property包,在下文中一共展示了Duration类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addDefaultReminders
import net.fortuna.ical4j.model.property.Duration; //导入依赖的package包/类
private void addDefaultReminders(VEvent vEvent, EventEntity event) {
VAlarm oneWeekBefore = new VAlarm(new Dur(-7, 0, 0, 0));
VAlarm oneDayBefore = new VAlarm(new Dur(-1, 0, 0, 0));
VAlarm oneHourBefore = new VAlarm(new Dur(0, -1, 0, 0));
oneHourBefore.getProperties().add(new Repeat(4));
oneHourBefore.getProperties().add(new Duration(new Dur(0, 0, 15, 0)));
addDisplayAction(event, oneWeekBefore);
addDisplayAction(event, oneDayBefore);
addDisplayAction(event, oneHourBefore);
vEvent.getAlarms().add(oneWeekBefore);
vEvent.getAlarms().add(oneDayBefore);
vEvent.getAlarms().add(oneHourBefore);
}
示例2: getDuration
import net.fortuna.ical4j.model.property.Duration; //导入依赖的package包/类
/**
* Get the duration for an event. If the DURATION property
* exist, use that. Else, calculate duration from DTSTART and
* DTEND.
* @param event The event.
* @return duration for event
*/
public static Dur getDuration(VEvent event) {
Duration duration = (Duration)
event.getProperties().getProperty(Property.DURATION);
if (duration != null) {
return duration.getDuration();
}
DtStart dtstart = event.getStartDate();
if (dtstart == null) {
return null;
}
DtEnd dtend = (DtEnd) event.getProperties().getProperty(Property.DTEND);
if (dtend == null) {
return null;
}
return new Duration(dtstart.getDate(), dtend.getDate()).getDuration();
}
示例3: toDuration
import net.fortuna.ical4j.model.property.Duration; //导入依赖的package包/类
protected static Duration toDuration(Double javaObj) {
if (javaObj == null) {
return null;
}
TimeDuration duration = TimeDuration.fromNumber(javaObj);
return new Duration(new Dur(duration.days(), duration.hours(), duration.minutes(), duration.seconds()));
}
示例4: getDisplayAlarmDuration
import net.fortuna.ical4j.model.property.Duration; //导入依赖的package包/类
public Dur getDisplayAlarmDuration() {
VAlarm alarm = getDisplayAlarm();
if(alarm==null) {
return null;
}
Duration dur = (Duration) alarm.getProperties().getProperty(Property.DURATION);
if(dur!=null) {
return dur.getDuration();
}
else {
return null;
}
}
示例5: fromDuration
import net.fortuna.ical4j.model.property.Duration; //导入依赖的package包/类
protected static Double fromDuration(PropertyList propertyList) {
Duration iCalObj = (Duration) propertyList.getProperty(Duration.DURATION);
if (iCalObj == null) {
return null;
}
Dur dur = iCalObj.getDuration();
TimeDuration td = new TimeDuration(0, 0, (dur.getWeeks() * 7) + dur.getDays(), dur.getHours(), dur.getMinutes(), dur.getSeconds(), 0);
return new Double(TimeDuration.toLong(td));
}
示例6: createEventPropertyList
import net.fortuna.ical4j.model.property.Duration; //导入依赖的package包/类
private PropertyList createEventPropertyList() {
PropertyList propertyList = new PropertyList();
DtStart dtStart = new DtStart(new Date(event.getEventStartDate()));
Duration duration = new Duration(new Dur(0, 1, 0, 0));
propertyList.add(dtStart);
propertyList.add(createRepeatRule(event));
propertyList.add(duration);
return propertyList;
}
示例7: getTriggerDates
import net.fortuna.ical4j.model.property.Duration; //导入依赖的package包/类
/**
* Return the list of dates that an alarm will trigger.
* @param alarm alarm component
* @param parent parent compoennt (VEvent,VToDo)
* @return dates that alarm is configured to trigger
*/
public static List<Date> getTriggerDates(VAlarm alarm, Component parent) {
ArrayList<Date> dates = new ArrayList<Date>();
Trigger trigger = alarm.getTrigger();
if(trigger==null) {
return dates;
}
Date initialTriggerDate = getTriggerDate(trigger, parent);
if(initialTriggerDate==null) {
return dates;
}
dates.add(initialTriggerDate);
Duration dur = alarm.getDuration();
if(dur==null) {
return dates;
}
Repeat repeat = alarm.getRepeat();
if(repeat==null) {
return dates;
}
Date nextTriggerDate = initialTriggerDate;
for(int i=0;i<repeat.getCount();i++) {
nextTriggerDate = Dates.getInstance(dur.getDuration().getTime(nextTriggerDate), nextTriggerDate);
dates.add(nextTriggerDate);
}
return dates;
}
示例8: getDisplayAlarmDuration
import net.fortuna.ical4j.model.property.Duration; //导入依赖的package包/类
/**
* Gets display alarm duration.
* @return The duration.
*/
public Dur getDisplayAlarmDuration() {
VAlarm alarm = getDisplayAlarm();
if (alarm == null) {
return null;
}
Duration dur = (Duration) alarm.getProperties().getProperty(Property.DURATION);
if (dur != null) {
return dur.getDuration();
}
else {
return null;
}
}
示例9: getTriggerDate
import net.fortuna.ical4j.model.property.Duration; //导入依赖的package包/类
/**
* Return the date that a trigger refers to, which can be an absolute
* date or a date relative to the start or end time of a parent
* component (VEVENT/VTODO).
* @param trigger The trigger.
* @param parent The component.
* @return date of trigger.
*/
public static Date getTriggerDate(Trigger trigger, Component parent) {
if(trigger==null) {
return null;
}
// if its absolute then we are done
if(trigger.getDateTime()!=null) {
return trigger.getDateTime();
}
// otherwise we need a start date if VEVENT
DtStart start = (DtStart) parent.getProperty(Property.DTSTART);
if(start==null && parent instanceof VEvent) {
return null;
}
// is trigger relative to start or end
Related related = (Related) trigger.getParameter(Parameter.RELATED);
if(related==null || related.equals(Related.START)) {
// must have start date
if(start==null) {
return null;
}
// relative to start
return Dates.getInstance(trigger.getDuration().getTime(start.getDate()), start.getDate());
} else {
// relative to end
Date endDate = null;
// need an end date or duration or due
DtEnd end = (DtEnd) parent.getProperty(Property.DTEND);
if(end!=null) {
endDate = end.getDate();
}
if(endDate==null) {
Duration dur = (Duration) parent.getProperty(Property.DURATION);
if(dur!=null && start!=null) {
endDate= Dates.getInstance(dur.getDuration().getTime(start.getDate()), start.getDate());
}
}
if(endDate==null) {
Due due = (Due) parent.getProperty(Property.DUE);
if(due!=null) {
endDate = due.getDate();
}
}
// require end date
if(endDate==null) {
return null;
}
return Dates.getInstance(trigger.getDuration().getTime(endDate), endDate);
}
}