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

Java Duration类代码示例

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

本文整理汇总了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);
}
 
开发者ID:adrobisch,项目名称:putput,代码行数:18,代码来源:EventsResource.java


示例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();
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:24,代码来源:ICalendarUtils.java


示例3: 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));
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:10,代码来源:ICalConverter.java


示例4: 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()));
}
 
开发者ID:ilscipio,项目名称:scipio-erp,代码行数:8,代码来源:ICalConverter.java


示例5: 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;
}
 
开发者ID:memfis19,项目名称:Cadar,代码行数:13,代码来源:EventComponentCreator.java


示例6: 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;
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:38,代码来源:ICalendarUtils.java


示例7: 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;
    }
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:15,代码来源:HibBaseEventStamp.java


示例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;
    }
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:19,代码来源:MockBaseEventStamp.java


示例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);
    }
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:68,代码来源:ICalendarUtils.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java ServerLocationPerORB类代码示例发布时间:2022-05-22
下一篇:
Java Event类代码示例发布时间: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