本文整理汇总了Java中net.fortuna.ical4j.model.property.DtStart类的典型用法代码示例。如果您正苦于以下问题:Java DtStart类的具体用法?Java DtStart怎么用?Java DtStart使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DtStart类属于net.fortuna.ical4j.model.property包,在下文中一共展示了DtStart类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCalendar
import net.fortuna.ical4j.model.property.DtStart; //导入依赖的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: evaluateVJournalTimeRange
import net.fortuna.ical4j.model.property.DtStart; //导入依赖的package包/类
/**
* Evaluates VJournal time range.
* @param journal The VJournal.
* @param filter The time range filter.
* @return The result.
*/
private boolean evaluateVJournalTimeRange(VJournal journal, TimeRangeFilter filter) {
DtStart start = journal.getStartDate();
if(start==null) {
return false;
}
InstanceList instances = new InstanceList();
if (filter.getTimezone() != null) {
instances.setTimezone(new TimeZone(filter.getTimezone()));
}
instances.addComponent(journal, filter.getPeriod().getStart(),
filter.getPeriod().getEnd());
return instances.size() > 0;
}
示例3: getDuration
import net.fortuna.ical4j.model.property.DtStart; //导入依赖的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: setAnyTime
import net.fortuna.ical4j.model.property.DtStart; //导入依赖的package包/类
public void setAnyTime(Boolean isAnyTime) {
DtStart dtStart = getEvent().getStartDate();
if (dtStart == null) {
throw new IllegalStateException("event has no start date");
}
Parameter parameter = dtStart.getParameters().getParameter(
PARAM_X_OSAF_ANYTIME);
// add X-OSAF-ANYTIME if it doesn't exist
if (parameter == null && Boolean.TRUE.equals(isAnyTime)) {
dtStart.getParameters().add(getAnyTimeXParam());
return;
}
// if it exists, update based on isAnyTime
if (parameter != null) {
dtStart.getParameters().remove(parameter);
if (Boolean.TRUE.equals(isAnyTime)) {
dtStart.getParameters().add(getAnyTimeXParam());
}
}
}
示例5: setAnyTime
import net.fortuna.ical4j.model.property.DtStart; //导入依赖的package包/类
/**
* Toggle the event exception anytime parameter.
* @param isAnyTime True if the event occurs anytime<br/>
* False if the event does not occur anytime</br>
* null if the event should inherit the anyTime
* attribute of the master event.
*/
@Override
public void setAnyTime(Boolean isAnyTime) {
// Interpret null as "missing" anyTime, meaning inherited from master
if(isAnyTime==null) {
DtStart dtStart = getEvent().getStartDate();
if (dtStart == null) {
throw new IllegalStateException("event has no start date");
}
Parameter parameter = dtStart.getParameters().getParameter(
PARAM_X_OSAF_ANYTIME);
if(parameter!=null) {
dtStart.getParameters().remove(parameter);
}
// "missing" anyTime is represented as X-OSAF-ANYTIME=MISSING
dtStart.getParameters().add(getInheritedAnyTimeXParam());
} else {
super.setAnyTime(isAnyTime);
}
}
示例6: isAnyTime
import net.fortuna.ical4j.model.property.DtStart; //导入依赖的package包/类
/**
* Is the event exception marked as anytime.
* @return True if the event is an anytime event<br/>
* False if it is not an anytime event<br/>
* null if the anyTime attribute is "missing", ie inherited
* from the master event.
*/
@Override
public Boolean isAnyTime() {
DtStart dtStart = getEvent().getStartDate();
if (dtStart == null) {
return Boolean.FALSE;
}
Parameter parameter = dtStart.getParameters()
.getParameter(PARAM_X_OSAF_ANYTIME);
if (parameter == null) {
return Boolean.FALSE;
}
// return null for "missing" anyTime
if(!VALUE_MISSING.equals(parameter.getValue())) {
return Boolean.valueOf(VALUE_TRUE.equals(parameter.getValue()));
}
return Boolean.FALSE;
}
示例7: isEventValid
import net.fortuna.ical4j.model.property.DtStart; //导入依赖的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);
}
示例8: setAnyTime
import net.fortuna.ical4j.model.property.DtStart; //导入依赖的package包/类
/**
* Sets any time.
* @param isAnyTime Boolean.
*/
@Override
public void setAnyTime(Boolean isAnyTime) {
// Interpret null as "missing" anyTime, meaning inherited from master
if(isAnyTime==null) {
DtStart dtStart = getEvent().getStartDate();
if (dtStart == null) {
throw new IllegalStateException("event has no start date");
}
Parameter parameter = dtStart.getParameters().getParameter(
PARAM_X_OSAF_ANYTIME);
if (parameter != null) {
dtStart.getParameters().remove(parameter);
}
// "missing" anyTime is represented as X-OSAF-ANYTIME=MISSING
dtStart.getParameters().add(getInheritedAnyTimeXParam());
} else {
super.setAnyTime(isAnyTime);
}
}
示例9: isAnyTime
import net.fortuna.ical4j.model.property.DtStart; //导入依赖的package包/类
/**
* Is any time.
* @return boolean.
*/
@Override
public Boolean isAnyTime() {
DtStart dtStart = getEvent().getStartDate();
if (dtStart == null) {
return Boolean.FALSE;
}
Parameter parameter = dtStart.getParameters()
.getParameter(PARAM_X_OSAF_ANYTIME);
if (parameter == null) {
return Boolean.FALSE;
}
// return null for "missing" anyTime
if (VALUE_MISSING.equals(parameter.getValue())) {
return null;
}
return Boolean.valueOf(VALUE_TRUE.equals(parameter.getValue()));
}
示例10: setAnyTime
import net.fortuna.ical4j.model.property.DtStart; //导入依赖的package包/类
/**
* Sets any time.
* @param isAnyTime isAnyTime.
*/
public void setAnyTime(Boolean isAnyTime) {
DtStart dtStart = getEvent().getStartDate();
if (dtStart == null) {
throw new IllegalStateException("event has no start date");
}
Parameter parameter = dtStart.getParameters().getParameter(
PARAM_X_OSAF_ANYTIME);
// add X-OSAF-ANYTIME if it doesn't exist
if (parameter == null && Boolean.TRUE.equals(isAnyTime)) {
dtStart.getParameters().add(getAnyTimeXParam());
return;
}
// if it exists, update based on isAnyTime
if (parameter != null) {
dtStart.getParameters().remove(parameter);
if (Boolean.TRUE.equals(isAnyTime)) {
dtStart.getParameters().add(getAnyTimeXParam());
}
}
}
示例11: testCreateContentThrowsExceptionForInvalidDates
import net.fortuna.ical4j.model.property.DtStart; //导入依赖的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);
}
示例12: testUpdateCollectionFailsForEventsWithInvalidDates
import net.fortuna.ical4j.model.property.DtStart; //导入依赖的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));
}
示例13: fromDtStart
import net.fortuna.ical4j.model.property.DtStart; //导入依赖的package包/类
protected static Timestamp fromDtStart(PropertyList propertyList) {
DtStart iCalObj = (DtStart) propertyList.getProperty(DtStart.DTSTART);
if (iCalObj == null) {
return null;
}
Date date = iCalObj.getDate();
return new Timestamp(date.getTime());
}
示例14: createEventPropertyList
import net.fortuna.ical4j.model.property.DtStart; //导入依赖的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;
}
示例15: getStartDate
import net.fortuna.ical4j.model.property.DtStart; //导入依赖的package包/类
/**
* Gets start date.
* @param comp The component.
* @return The date.
*/
private Date getStartDate(Component comp) {
final DtStart dtStart = ICalendarUtils.getStartDate(comp);
if(dtStart != null) {
return dtStart.getDate();
}
return null;
}