本文整理汇总了Java中net.fortuna.ical4j.model.Dur类的典型用法代码示例。如果您正苦于以下问题:Java Dur类的具体用法?Java Dur怎么用?Java Dur使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Dur类属于net.fortuna.ical4j.model包,在下文中一共展示了Dur类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addDefaultReminders
import net.fortuna.ical4j.model.Dur; //导入依赖的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: createMailText
import net.fortuna.ical4j.model.Dur; //导入依赖的package包/类
private static String createMailText(final URL calendarUrl, final File groupDirectory)
throws IOException, ParserException, ParserConfigurationException, SAXException {
final Calendar mergedCalendar = loadCalendar(calendarUrl);
final Period nextPeriod = new Period(new DateTime(), new Dur(1));
return "== Meet-Hub-Hannover Veranstaltungs-Newsletter ==\n" +
"\n" +
"Nächste Woche:\n" +
formatNextEvents(mergedCalendar, nextPeriod) +
"\n" +
"Danach:\n" +
formatLaterEvents(mergedCalendar, nextPeriod) +
"\n" +
"Beteiligte Gruppen:\n" +
formatGroups(groupDirectory) +
"\n" +
"==============================================\n" +
"*|LIST:DESCRIPTION|*\n" +
"\n" +
"Die E-Mail-Adresse *|EMAIL|* vom Newsletter abmelden:\n" +
"*|UNSUB|*\n";
}
示例3: getDuration
import net.fortuna.ical4j.model.Dur; //导入依赖的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();
}
示例4: getDurToUseForExpanding
import net.fortuna.ical4j.model.Dur; //导入依赖的package包/类
/**
*
* @param es EventStamp
* @param later boolean
* @return Dur
*/
private Dur getDurToUseForExpanding(EventStamp es, boolean later) {
List<Recur> rules = es.getRecurrenceRules();
// No rules, assume RDATEs so expand a year
if(rules.size()==0) {
return later ? yearLaterDur : yearDoneDur;
}
// Look at first rule only
Recur recur = rules.get(0);
// If rule is yearly or monthly then expand a year,
// otherwise only expand a month
if(Recur.YEARLY.equals(recur.getFrequency()) ||
Recur.MONTHLY.equals(recur.getFrequency())) {
return later ? yearLaterDur : yearDoneDur;
}
else {
return later ? monthLaterDur : monthDoneDur;
}
}
示例5: checkMoment
import net.fortuna.ical4j.model.Dur; //导入依赖的package包/类
public boolean checkMoment(Date date) {
if (calendar != null) {
Period period = new Period(new DateTime(date), new Dur(0, 0, 0, 0));
Predicate<CalendarComponent> periodRule = new PeriodRule<>(period);
Filter<CalendarComponent> filter = new Filter<>(new Predicate[] {periodRule}, Filter.MATCH_ANY);
Collection<CalendarComponent> events = filter.filter(calendar.getComponents(CalendarComponent.VEVENT));
if (events != null && !events.isEmpty()) {
return true;
}
}
return false;
}
示例6: fromDuration
import net.fortuna.ical4j.model.Dur; //导入依赖的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));
}
示例7: toDuration
import net.fortuna.ical4j.model.Dur; //导入依赖的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()));
}
示例8: createEventPropertyList
import net.fortuna.ical4j.model.Dur; //导入依赖的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;
}
示例9: adjustStartRangeIfNecessary
import net.fortuna.ical4j.model.Dur; //导入依赖的package包/类
/**
* Adjust startRange to account for instances that begin before the given
* startRange, but end after. For example if you have a daily recurring event
* at 8am lasting for an hour and your startRange is 8:01am, then you
* want to adjust the range back an hour to catch the instance that is
* already occurring.
*
* @param startRange The date in range we want to adjust.
* @param start The date of the event.
* @param dur The duration.
* @return The adjusted start Range date.
*/
private Date adjustStartRangeIfNecessary(Date startRange, Date start, Dur dur) {
// If start is a Date, then we need to convert startRange to
// a Date using the timezone present
if (!(start instanceof DateTime) && timezone != null && startRange instanceof DateTime) {
return ICalendarUtils.normalizeUTCDateTimeToDate(
(DateTime) startRange, timezone);
}
// Otherwise start is a DateTime
// If startRange is not the event start, no adjustment necessary
if (!startRange.after(start)) {
return startRange;
}
// Need to adjust startRange back one duration to account for instances
// that occur before the startRange, but end after the startRange
Dur negatedDur = dur.negate();
Calendar cal = Dates.getCalendarInstance(startRange);
cal.setTime(negatedDur.getTime(startRange));
// Return new startRange only if it is before the original startRange
if (cal.getTime().before(startRange)) {
return org.unitedinternet.cosmo.calendar.util.Dates.getInstance(cal.getTime(), startRange);
}
return startRange;
}
示例10: getDisplayAlarmDuration
import net.fortuna.ical4j.model.Dur; //导入依赖的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;
}
}
示例11: getDisplayAlarmDuration
import net.fortuna.ical4j.model.Dur; //导入依赖的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;
}
}
示例12: createTestEvent
import net.fortuna.ical4j.model.Dur; //导入依赖的package包/类
private void createTestEvent(LocalCalendar calendar) {
try {
TimeZone tzVienna = DateUtils.tzRegistry.getTimeZone("Europe/Vienna");
Event event = new Event();
event.uid = "[email protected]";
event.summary = "Sample event";
event.description = "Sample event with date/time";
event.location = "Sample location";
event.dtStart = new DtStart("20150501T120000", tzVienna);
event.dtEnd = new DtEnd("20150501T130000", tzVienna);
event.organizer = new Organizer(new URI("mailto:[email protected]"));
event.rRule = new RRule("FREQ=DAILY;COUNT=10");
event.forPublic = false;
event.status = Status.VEVENT_CONFIRMED;
// set an alarm one day, two hours, three minutes and four seconds before begin of event
event.alarms.add(new VAlarm(new Dur(-1, -2, -3, -4)));
// add two attendees
event.attendees.add(new Attendee(new URI("mailto:[email protected]")));
event.attendees.add(new Attendee(new URI("mailto:[email protected]")));
// add exception with alarm and attendee
Event exception = new Event();
exception.recurrenceId = new RecurrenceId("20150502T120000", tzVienna);
exception.summary = "Exception for sample event";
exception.dtStart = new DtStart("20150502T140000", tzVienna);
exception.dtEnd = new DtEnd("20150502T150000", tzVienna);
exception.alarms.add(new VAlarm(new Dur(-2, -3, -4, -5)));
exception.attendees.add(new Attendee(new URI("mailto:[email protected]")));
event.exceptions.add(exception);
// add EXDATE
event.exDates.add(new ExDate(new DateList("20150502T120000", Value.DATE_TIME, tzVienna)));
// add to calendar
Uri uri = new LocalEvent(calendar, event, null, null).add();
showMessage("Event created: " + uri);
showEvents(calendar);
} catch (Exception e) {
e.printStackTrace();
showMessage(e.toString());
}
}
示例13: formatLaterEvents
import net.fortuna.ical4j.model.Dur; //导入依赖的package包/类
private static String formatLaterEvents(final Calendar c, final Period nextPeriod) {
final List<Event> filtered = Event.getEventsInPeriod(c, new Period(nextPeriod.getEnd(), new Dur(7)));
return filtered.isEmpty() ? " Keine Termine in der nächsten Zeit danach\n" : formatEvents(filtered);
}
示例14: getDuration
import net.fortuna.ical4j.model.Dur; //导入依赖的package包/类
public Dur getDuration() {
return ICalendarUtils.getDuration(getEvent());
}
示例15: setDuration
import net.fortuna.ical4j.model.Dur; //导入依赖的package包/类
public void setDuration(Dur dur) {
ICalendarUtils.setDuration(getEvent(), dur);
}