本文整理汇总了Java中net.fortuna.ical4j.model.property.DtEnd类的典型用法代码示例。如果您正苦于以下问题:Java DtEnd类的具体用法?Java DtEnd怎么用?Java DtEnd使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DtEnd类属于net.fortuna.ical4j.model.property包,在下文中一共展示了DtEnd类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCalendar
import net.fortuna.ical4j.model.property.DtEnd; //导入依赖的package包/类
public static Calendar createCalendar(CalDavEvent calDavEvent, DateTimeZone timeZone) {
TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
TimeZone timezone = registry.getTimeZone(timeZone.getID());
Calendar calendar = new Calendar();
calendar.getProperties().add(Version.VERSION_2_0);
calendar.getProperties().add(new ProdId("openHAB"));
VEvent vEvent = new VEvent();
vEvent.getProperties().add(new Summary(calDavEvent.getName()));
vEvent.getProperties().add(new Description(calDavEvent.getContent()));
final DtStart dtStart = new DtStart(new net.fortuna.ical4j.model.DateTime(calDavEvent.getStart().toDate()));
dtStart.setTimeZone(timezone);
vEvent.getProperties().add(dtStart);
final DtEnd dtEnd = new DtEnd(new net.fortuna.ical4j.model.DateTime(calDavEvent.getEnd().toDate()));
dtEnd.setTimeZone(timezone);
vEvent.getProperties().add(dtEnd);
vEvent.getProperties().add(new Uid(calDavEvent.getId()));
vEvent.getProperties().add(Clazz.PUBLIC);
vEvent.getProperties()
.add(new LastModified(new net.fortuna.ical4j.model.DateTime(calDavEvent.getLastChanged().toDate())));
calendar.getComponents().add(vEvent);
return calendar;
}
示例2: getDuration
import net.fortuna.ical4j.model.property.DtEnd; //导入依赖的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: isEventValid
import net.fortuna.ical4j.model.property.DtEnd; //导入依赖的package包/类
private static boolean isEventValid(VEvent event, ValidationConfig config){
DtStart startDate = event.getStartDate();
DtEnd endDate = event.getEndDate(true);
if(startDate == null ||
startDate.getDate() == null ||
endDate != null && startDate.getDate().after(endDate.getDate())){
return false;
}
for(PropertyValidator validator : values()){
if(!validator.isValid(event, config)){
return false;
}
}
return areTimeZoneIdsValid(event);
}
示例4: testCreateContentThrowsExceptionForInvalidDates
import net.fortuna.ical4j.model.property.DtEnd; //导入依赖的package包/类
@Test(expected=IllegalArgumentException.class)
public void testCreateContentThrowsExceptionForInvalidDates() throws Exception {
User user = testHelper.makeDummyUser();
CollectionItem rootCollection = contentDao.createRootItem(user);
NoteItem noteItem = new MockNoteItem();
noteItem.getAttributeValue("");
noteItem.setName("foo");
noteItem.setOwner(user);
Calendar c = new Calendar();
VEvent e = new VEvent();
e.getProperties().add(new DtStart("20131010T101010Z"));
e.getProperties().add(new DtEnd("20131010T091010Z"));
c.getComponents().add(e);
MockEventStamp mockEventStamp = new MockEventStamp();
mockEventStamp.setEventCalendar(c);
noteItem.addStamp(mockEventStamp);
service.createContent(rootCollection, noteItem);
}
示例5: testUpdateCollectionFailsForEventsWithInvalidDates
import net.fortuna.ical4j.model.property.DtEnd; //导入依赖的package包/类
@Test(expected=IllegalArgumentException.class)
public void testUpdateCollectionFailsForEventsWithInvalidDates() throws Exception {
User user = testHelper.makeDummyUser();
CollectionItem rootCollection = contentDao.createRootItem(user);
NoteItem noteItem = new MockNoteItem();
noteItem.getAttributeValue("");
noteItem.setName("foo");
noteItem.setOwner(user);
Calendar c = new Calendar();
VEvent e = new VEvent();
e.getProperties().add(new DtStart("20131010T101010Z"));
e.getProperties().add(new DtEnd("20131010T091010Z"));
c.getComponents().add(e);
MockEventStamp mockEventStamp = new MockEventStamp();
mockEventStamp.setEventCalendar(c);
noteItem.addStamp(mockEventStamp);
service.updateCollection(rootCollection, Collections.singleton((Item)noteItem));
}
示例6: fromDtEnd
import net.fortuna.ical4j.model.property.DtEnd; //导入依赖的package包/类
protected static Timestamp fromDtEnd(PropertyList propertyList) {
DtEnd iCalObj = (DtEnd) propertyList.getProperty(DtEnd.DTEND);
if (iCalObj == null) {
return null;
}
Date date = iCalObj.getDate();
return new Timestamp(date.getTime());
}
示例7: evaulateVFreeBusyTimeRange
import net.fortuna.ical4j.model.property.DtEnd; //导入依赖的package包/类
/**
* Evaluates VFreeBusy time range.
* @param freeBusy freebusy.
* @param filter The filter.
* @return The result.
*/
private boolean evaulateVFreeBusyTimeRange(VFreeBusy freeBusy, TimeRangeFilter filter) {
DtStart start = freeBusy.getStartDate();
DtEnd end = freeBusy.getEndDate();
if (start != null && end != null) {
InstanceList instances = new InstanceList();
if (filter.getTimezone() != null) {
instances.setTimezone(new TimeZone(filter.getTimezone()));
}
instances.addComponent(freeBusy, filter.getPeriod().getStart(),
filter.getPeriod().getEnd());
return instances.size() > 0;
}
PropertyList<FreeBusy> props = freeBusy.getProperties(Property.FREEBUSY);
if(props.size()==0) {
return false;
}
for (FreeBusy fb : props) {
PeriodList periods = fb.getPeriods();
Iterator<Period> periodIt = periods.iterator();
while(periodIt.hasNext()) {
Period period = periodIt.next();
if(filter.getPeriod().getStart().before(period.getEnd()) &&
filter.getPeriod().getEnd().after(period.getStart())) {
return true;
}
}
}
return false;
}
示例8: isOutOfRange
import net.fortuna.ical4j.model.property.DtEnd; //导入依赖的package包/类
private static boolean isOutOfRange(BaseEventStamp eventStamp, List<StampFilter> stampFilters)
throws ParseException {
for (StampFilter stampFilter : stampFilters) {
if (!(stampFilter instanceof EventStampFilter)) {
continue;
}
VEvent vEvent = null;
if (eventStamp instanceof EventStamp) {
vEvent = ((EventStamp) eventStamp).getMasterEvent();
} else if (eventStamp instanceof EventExceptionStamp) {
vEvent = ((EventExceptionStamp) eventStamp).getExceptionEvent();
} else {
throw new ExternalContentRuntimeException("Unknown event stamp class: " + eventStamp.getClass());
}
EventStampFilter eventFilter = (EventStampFilter) stampFilter;
Date dtStart = new DtStart(vEvent.getStartDate().getValue(), eventFilter.getTimezone()).getDate();
Date dtEnd = new DtEnd(vEvent.getEndDate().getValue(), eventFilter.getTimezone()).getDate();
Date filterStartDate = new DateTime(eventFilter.getUTCStart());
Date filterEndDate = new DateTime(eventFilter.getUTCEnd());
if (dtStart.after(filterEndDate) || dtStart.equals(filterEndDate) || dtEnd.before(filterStartDate)
|| dtEnd.equals(filterStartDate)) {
return true;
}
}
return false;
}
示例9: checkDatesForComponent
import net.fortuna.ical4j.model.property.DtEnd; //导入依赖的package包/类
private void checkDatesForComponent(Component component){
if(component == null){
return;
}
Property dtStart = component.getProperty(Property.DTSTART);
Property dtEnd = component.getProperty(Property.DTEND);
if( dtStart instanceof DtStart && dtStart.getValue()!= null
&& dtEnd instanceof DtEnd && dtEnd.getValue() != null
&& ((DtStart)dtStart).getDate().compareTo(((DtEnd)dtEnd).getDate()) > 0 ){
throw new IllegalArgumentException("End date [" + dtEnd + " is lower than start date [" + dtStart + "]");
}
}
示例10: createEventCalendarWithDates
import net.fortuna.ical4j.model.property.DtEnd; //导入依赖的package包/类
private Calendar createEventCalendarWithDates(String start, String end) throws ParseException{
Calendar c = new Calendar();
VEvent e = new VEvent();
e.getProperties().add(new DtStart(start));
e.getProperties().add(new DtEnd(end));
c.getComponents().add(e);
return c;
}
示例11: findOrCreateEvent
import net.fortuna.ical4j.model.property.DtEnd; //导入依赖的package包/类
@Transactional
protected ICalendarEvent findOrCreateEvent(VEvent vEvent, ICalendar calendar) {
String uid = vEvent.getUid().getValue();
DtStart dtStart = vEvent.getStartDate();
DtEnd dtEnd = vEvent.getEndDate();
ICalendarEvent event = iEventRepo.findByUid(uid);
if (event == null) {
event = new ICalendarEvent();
event.setUid(uid);
event.setCalendar(calendar);
}
event.setStartDateTime(new LocalDateTime(dtStart.getDate()));
event.setEndDateTime(new LocalDateTime(dtEnd.getDate()));
event.setAllDay(!(dtStart.getDate() instanceof DateTime));
event.setSubject(getValue(vEvent, Property.SUMMARY));
event.setDescription(getValue(vEvent, Property.DESCRIPTION));
event.setLocation(getValue(vEvent, Property.LOCATION));
event.setGeo(getValue(vEvent, Property.GEO));
event.setUrl(getValue(vEvent, Property.URL));
ICalendarUser organizer = findOrCreateUser(vEvent.getOrganizer());
if (organizer != null) {
event.setOrganizer(organizer);
iCalendarUserRepository.save(organizer);
}
for (Object item : vEvent.getProperties(Property.ATTENDEE)) {
ICalendarUser attendee = findOrCreateUser((Property) item);
if (attendee != null) {
event.addAttendee(attendee);
iCalendarUserRepository.save(attendee);
}
}
return event;
}
示例12: checkTimeZone
import net.fortuna.ical4j.model.property.DtEnd; //导入依赖的package包/类
private void checkTimeZone(VEvent event, TimeZone timezone) {
DtStart dtStart = event.getStartDate();
if (dtStart.getTimeZone() == null) {
dtStart.setTimeZone(timezone);
}
DtEnd dtEnd = event.getEndDate();
if (dtEnd.getTimeZone() == null) {
dtEnd.setTimeZone(timezone);
}
}
示例13: fillSingleComponent
import net.fortuna.ical4j.model.property.DtEnd; //导入依赖的package包/类
/**
* Creates a copy of a component which doesn't contain the original component's
* recurrence information.
*
* @param component
* - the component to be filled
* @param date
* - the startDate that will be assigned to the component
* @param duration
* - the duration (only relevant for events)
*/
private void fillSingleComponent(Component component, Date date,
long duration) {
// copy all the properties from the original component
PropertyList list = getPropertyList(component);
// if the component is an event perform event-specific actions
if (component instanceof VEvent) {
// the new endDate of this single event will
// be the previously calculated duration in combination
// with the current startDate
Date newEndDate = new DateTime(date.getTime() + duration);
// add new dates to the property list
list.add(new DtStart(date));
list.add(new DtEnd(newEndDate));
// create a new event with the properties of the property list
// and add it to the temporalDataSet
VEvent singleEvent = new VEvent(list);
fillEvent(singleEvent);
} else if (component instanceof VJournal) { // otherwise perfom
// journal-specific actions
// set the time stamp of the new journal
// to the current nextDate (occurrence)
list.add(new DtStamp((DateTime) date));
// create a new journal with the properties
// and add it to the temporalDataSet
VJournal singleJournal = new VJournal(list);
fillJournal(singleJournal);
}
}
示例14: createTestEvent
import net.fortuna.ical4j.model.property.DtEnd; //导入依赖的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());
}
}
示例15: toDtEnd
import net.fortuna.ical4j.model.property.DtEnd; //导入依赖的package包/类
protected static DtEnd toDtEnd(Timestamp javaObj) {
if (javaObj == null) {
return null;
}
return new DtEnd(new DateTime(javaObj));
}