本文整理汇总了Java中com.google.ical.values.DateValue.compareTo方法的典型用法代码示例。如果您正苦于以下问题:Java DateValue.compareTo方法的具体用法?Java DateValue.compareTo怎么用?Java DateValue.compareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.ical.values.DateValue
的用法示例。
在下文中一共展示了DateValue.compareTo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateInstance
import com.google.ical.values.DateValue; //导入方法依赖的package包/类
/**
* @return a date value in UTC.
*/
private DateValue generateInstance() {
try {
do {
if (!this.instanceGenerator_.generate(this.builder_)) {
return null;
}
DateValue dUtc = this.dtStart_ instanceof TimeValue
? TimeUtils.toUtc(this.builder_.toDateTime(), this.tzid_)
: this.builder_.toDate();
if (dUtc.compareTo(this.lastUtc_) > 0) {
return dUtc;
}
} while (true);
} catch (Generator.IteratorShortCircuitingException ex) {
return null;
}
}
示例2: goldenDateRange
import com.google.ical.values.DateValue; //导入方法依赖的package包/类
public String goldenDateRange(String dateStr, int interval) throws Exception {
PeriodValue period = IcalParseUtil.parsePeriodValue(dateStr);
DTBuilder b = new DTBuilder(period.start());
StringBuilder out = new StringBuilder();
while (true) {
DateValue d = b.toDate();
if (d.compareTo(period.end()) > 0) {
break;
}
if (0 != out.length()) {
out.append(',');
}
out.append(d);
b.day += interval;
}
return out.toString();
}
示例3: invokeRecurrence
import com.google.ical.values.DateValue; //导入方法依赖的package包/类
private static long invokeRecurrence(RRule rrule, DateTime original, DateValue startDateAsDV) {
long newDueDate = -1;
RecurrenceIterator iterator = RecurrenceIteratorFactory.createRecurrenceIterator(rrule,
startDateAsDV, TimeZone.getDefault());
DateValue nextDate;
for(int i = 0; i < 10; i++) { // ten tries then we give up
if(!iterator.hasNext()) {
return -1;
}
nextDate = iterator.next();
if(nextDate.compareTo(startDateAsDV) == 0) {
continue;
}
newDueDate = buildNewDueDate(original, nextDate);
// detect if we finished
if(newDueDate > original.getMillis()) {
break;
}
}
return newDueDate;
}
示例4: untilCondition
import com.google.ical.values.DateValue; //导入方法依赖的package包/类
/**
* constructs a condition that passes for every date on or before until.
* @param until non null.
*/
static Predicate<DateValue> untilCondition(final DateValue until) {
return new Predicate<DateValue>() {
public boolean apply(DateValue date) {
return date.compareTo(until) <= 0;
}
@Override
public String toString() {
return "UntilCondition:" + until;
}
};
}
示例5: advanceTo
import com.google.ical.values.DateValue; //导入方法依赖的package包/类
/**
* Skip all instances of the recurrence before the given date, so that
* the next call to {@link #next} will return a date on or after the given
* date, assuming the recurrence includes such a date.
*/
public void advanceTo(DateValue dateUtc) {
// Don't throw away a future pending date since the iterators will not
// generate it again.
if (this.pendingUtc_ != null && dateUtc.compareTo(this.pendingUtc_) <= 0) {
return;
}
DateValue dateLocal = TimeUtils.fromUtc(dateUtc, tzid_);
// Short-circuit if we're already past dateUtc.
if (dateLocal.compareTo(this.builder_.toDate()) <= 0) {
return;
}
this.pendingUtc_ = null;
try {
if (this.canShortcutAdvance_) {
// skip years before date.year
if (this.builder_.year < dateLocal.year()) {
do {
if (!this.yearGenerator_.generate(this.builder_)) {
this.done_ = true;
return;
}
} while (this.builder_.year < dateLocal.year());
while (!this.monthGenerator_.generate(this.builder_)) {
if (!this.yearGenerator_.generate(this.builder_)) {
this.done_ = true;
return;
}
}
}
// skip months before date.year/date.month
while (this.builder_.year == dateLocal.year()
&& this.builder_.month < dateLocal.month()) {
while (!this.monthGenerator_.generate(this.builder_)) {
// if there are more years available fetch one
if (!this.yearGenerator_.generate(this.builder_)) {
// otherwise the recurrence is exhausted
this.done_ = true;
return;
}
}
}
}
// consume any remaining instances
while (!this.done_) {
DateValue dUtc = this.generateInstance();
if (null == dUtc) {
this.done_ = true;
} else {
if (!this.condition_.apply(dUtc)) {
this.done_ = true;
} else if (dUtc.compareTo(dateUtc) >= 0) {
this.pendingUtc_ = dUtc;
break;
}
}
}
} catch (Generator.IteratorShortCircuitingException ex) {
this.done_ = true;
}
}