本文整理汇总了Java中net.fortuna.ical4j.util.Dates类的典型用法代码示例。如果您正苦于以下问题:Java Dates类的具体用法?Java Dates怎么用?Java Dates使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Dates类属于net.fortuna.ical4j.util包,在下文中一共展示了Dates类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isOccurrence
import net.fortuna.ical4j.util.Dates; //导入依赖的package包/类
/**
* Determine if date is a valid occurence in recurring calendar component
* @param calendar recurring calendar component
* @param occurrence occurrence date
* @return true if the occurrence date is a valid occurrence, otherwise false
*/
public boolean isOccurrence(Calendar calendar, Date occurrence) {
java.util.Calendar cal = Dates.getCalendarInstance(occurrence);
cal.setTime(occurrence);
// Add a second or day (one unit forward) so we can set a range for
// finding instances. This is required because ical4j's Recur apis
// only calculate recurring dates up until but not including the
// end date of the range.
if(occurrence instanceof DateTime) {
cal.add(java.util.Calendar.SECOND, 1);
}
else {
cal.add(java.util.Calendar.DAY_OF_WEEK, 1);
}
Date rangeEnd =
org.unitedinternet.cosmo.calendar.util.Dates.getInstance(cal.getTime(), occurrence);
InstanceList instances = getOcurrences(calendar, occurrence, rangeEnd, null);
for(Iterator<Instance> it = instances.values().iterator(); it.hasNext();) {
Instance instance = it.next();
if(instance.getRid().getTime()==occurrence.getTime()) {
return true;
}
}
return false;
}
示例2: adjustStartRangeIfNecessary
import net.fortuna.ical4j.util.Dates; //导入依赖的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;
}
示例3: isOccurrence
import net.fortuna.ical4j.util.Dates; //导入依赖的package包/类
/**
* Determine if date is a valid occurence in recurring calendar component
* @param calendar recurring calendar component
* @param occurrence occurrence date
* @return true if the occurrence date is a valid occurrence, otherwise false
*/
public boolean isOccurrence(Calendar calendar, Date occurrence) {
java.util.Calendar cal = Dates.getCalendarInstance(occurrence);
cal.setTime(occurrence);
// Add a second or day (one unit forward) so we can set a range for
// finding instances. This is required because ical4j's Recur apis
// only calculate recurring dates up until but not including the
// end date of the range.
if(occurrence instanceof DateTime) {
cal.add(java.util.Calendar.SECOND, 1);
}
else {
cal.add(java.util.Calendar.DAY_OF_WEEK, 1);
}
Date rangeEnd =
org.unitedinternet.cosmo.calendar.util.Dates.getInstance(cal.getTime(), occurrence);
TimeZone tz = null;
for(Object obj : calendar.getComponents(Component.VEVENT)){
VEvent evt = (VEvent)obj;
if(evt.getRecurrenceId() == null && evt.getStartDate() != null){
tz = evt.getStartDate().getTimeZone();
}
}
InstanceList instances = getOcurrences(calendar, occurrence, rangeEnd, tz);
for(Iterator<Instance> it = instances.values().iterator(); it.hasNext();) {
Instance instance = it.next();
if(instance.getRid().getTime()==occurrence.getTime()) {
return true;
}
}
return false;
}
示例4: makeWelcomeItem
import net.fortuna.ical4j.util.Dates; //导入依赖的package包/类
private NoteItem makeWelcomeItem(OutOfTheBoxContext context) {
NoteItem item = entityFactory.createNote();
TimeZone tz= context.getTimezone();
Locale locale = context.getLocale();
User user = context.getUser();
String name = "Welcome to Chandler Server";
String body = "1. Get a tour of Chandler @ chandlerproject.org/getstarted\n\n2. Consult our FAQ @ chandlerproject.org/faq\n\n3. Read about any known issues with the Preview release @ chandlerproject.org/knownissues\n\n4. Ask questions and give us feedback by joining the Chandler-Users mailing list @ chandlerproject.org/mailinglists. Find out how to get involved @ chandlerproject.org/getinvolved\n\n5. Learn more about the project and access a wide range of design, planning and developer documentation @ chandlerproject.org/wikihome";
String from = "OSAF";
String sentBy = "OSAF";
String to = "";
item.setUid(contentDao.generateUid());
item.setDisplayName(name);
item.setOwner(user);
item.setClientCreationDate(Calendar.getInstance(tz, locale).getTime());
item.setClientModifiedDate(item.getClientCreationDate());
TriageStatus triage = entityFactory.createTriageStatus();
TriageStatusUtil.initialize(triage);
item.setTriageStatus(triage);
item.setLastModifiedBy(user.getUsername());
item.setLastModification(ContentItem.Action.CREATED);
item.setSent(Boolean.FALSE);
item.setNeedsReply(Boolean.FALSE);
item.setIcalUid(item.getUid());
item.setBody(body);
Calendar start = Calendar.getInstance(tz, locale);
start.set(Calendar.MINUTE, 0);
start.set(Calendar.SECOND, 0);
DateTime startDate = (DateTime)
Dates.getInstance(start.getTime(), Value.DATE_TIME);
startDate.setTimeZone(vtz(tz.getID()));
EventStamp es = entityFactory.createEventStamp(item);
item.addStamp(es);
es.createCalendar();
es.setStartDate(startDate);
es.setDuration(new Dur(0, 1, 0, 0));
TaskStamp ts = entityFactory.createTaskStamp();
item.addStamp(ts);
MessageStamp ms = entityFactory.createMessageStamp();
item.addStamp(ms);
ms.setFrom(from);
ms.setTo(to);
ms.setOriginators(sentBy);
ms.setDateSent(DateUtil.formatDate(MessageStamp.FORMAT_DATE_SENT,
item.getClientCreationDate()));
return item;
}
示例5: makeTryOutItem
import net.fortuna.ical4j.util.Dates; //导入依赖的package包/类
private NoteItem makeTryOutItem(OutOfTheBoxContext context) {
NoteItem item = entityFactory.createNote();
TimeZone tz= context.getTimezone();
Locale locale = context.getLocale();
User user = context.getUser();
String name = "Download Chandler Desktop";
String body = "Learn more @ chandlerproject.org\n\nDownload @ chandlerproject.org/download";
TriageStatus triage = entityFactory.createTriageStatus();
TriageStatusUtil.initialize(triage);
triage.setCode(TriageStatus.CODE_LATER);
item.setUid(contentDao.generateUid());
item.setDisplayName(name);
item.setOwner(user);
item.setClientCreationDate(Calendar.getInstance(tz, locale).getTime());
item.setClientModifiedDate(item.getClientCreationDate());
item.setTriageStatus(triage);
item.setLastModifiedBy(user.getUsername());
item.setLastModification(ContentItem.Action.CREATED);
item.setSent(Boolean.FALSE);
item.setNeedsReply(Boolean.FALSE);
item.setIcalUid(item.getUid());
item.setBody(body);
Calendar start = Calendar.getInstance(tz, locale);
start.add(Calendar.DAY_OF_MONTH, 1);
start.set(Calendar.HOUR_OF_DAY, 10);
start.set(Calendar.MINUTE, 0);
start.set(Calendar.SECOND, 0);
DateTime startDate = (DateTime)
Dates.getInstance(start.getTime(), Value.DATE_TIME);
startDate.setTimeZone(vtz(tz.getID()));
EventStamp es = entityFactory.createEventStamp(item);
item.addStamp(es);
es.createCalendar();
es.setStartDate(startDate);
es.setDuration(new Dur(0, 1, 0, 0));
TaskStamp ts = entityFactory.createTaskStamp();
item.addStamp(ts);
return item;
}
示例6: MyIcal4JDate
import net.fortuna.ical4j.util.Dates; //导入依赖的package包/类
MyIcal4JDate(final java.util.Date javaDate, final java.util.TimeZone timeZone)
{
super(javaDate.getTime(), Dates.PRECISION_DAY, timeZone);
}