本文整理汇总了Java中com.google.ical.values.DateValue类的典型用法代码示例。如果您正苦于以下问题:Java DateValue类的具体用法?Java DateValue怎么用?Java DateValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DateValue类属于com.google.ical.values包,在下文中一共展示了DateValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dateValueToDateTime
import com.google.ical.values.DateValue; //导入依赖的package包/类
static DateTime dateValueToDateTime(DateValue dvUtc) {
if (dvUtc instanceof TimeValue) {
TimeValue tvUtc = (TimeValue) dvUtc;
return new DateTime(
dvUtc.year(),
dvUtc.month(), // java.util's dates are zero-indexed
dvUtc.day(),
tvUtc.hour(),
tvUtc.minute(),
tvUtc.second(),
0,
DateTimeZone.UTC);
} else {
return new DateTime(
dvUtc.year(),
dvUtc.month(), // java.util's dates are zero-indexed
dvUtc.day(),
0,
0,
0,
0,
DateTimeZone.UTC);
}
}
示例2: dateValueToDate
import com.google.ical.values.DateValue; //导入依赖的package包/类
static Date dateValueToDate(DateValue dvUtc) {
GregorianCalendar c = new GregorianCalendar(TimeUtils.utcTimezone());
c.clear();
if (dvUtc instanceof TimeValue) {
TimeValue tvUtc = (TimeValue) dvUtc;
c.set(dvUtc.year(),
dvUtc.month() - 1, // java.util's dates are zero-indexed
dvUtc.day(),
tvUtc.hour(),
tvUtc.minute(),
tvUtc.second());
} else {
c.set(dvUtc.year(),
dvUtc.month() - 1, // java.util's dates are zero-indexed
dvUtc.day(),
0,
0,
0);
}
return c.getTime();
}
示例3: dateToDateValue
import com.google.ical.values.DateValue; //导入依赖的package包/类
static DateValue dateToDateValue(Date date, boolean midnightAsDate) {
GregorianCalendar c = new GregorianCalendar(TimeUtils.utcTimezone());
c.setTime(date);
int h = c.get(Calendar.HOUR_OF_DAY),
m = c.get(Calendar.MINUTE),
s = c.get(Calendar.SECOND);
if (midnightAsDate && 0 == (h | m | s)) {
return new DateValueImpl(c.get(Calendar.YEAR),
c.get(Calendar.MONTH) + 1,
c.get(Calendar.DAY_OF_MONTH));
} else {
return new DateTimeValueImpl(c.get(Calendar.YEAR),
c.get(Calendar.MONTH) + 1,
c.get(Calendar.DAY_OF_MONTH),
h,
m,
s);
}
}
示例4: dateValueToDateTime
import com.google.ical.values.DateValue; //导入依赖的package包/类
static ZonedDateTime dateValueToDateTime(DateValue dvUtc) {
if (dvUtc instanceof TimeValue) {
TimeValue tvUtc = (TimeValue) dvUtc;
return ZonedDateTime.of(
dvUtc.year(),
dvUtc.month(), // java.util's dates are zero-indexed
dvUtc.day(),
tvUtc.hour(),
tvUtc.minute(),
tvUtc.second(),
0,
ZoneId.of("UTC"));
} else {
return ZonedDateTime.of(
dvUtc.year(),
dvUtc.month(), // java.util's dates are zero-indexed
dvUtc.day(),
0,
0,
0,
0,
ZoneId.of("UTC"));
}
}
示例5: byMonthDayFilter
import com.google.ical.values.DateValue; //导入依赖的package包/类
/**
* constructs a day filter based on a BYDAY rule.
* @param monthDays days of the month in [-31, 31] != 0
*/
static Predicate<DateValue> byMonthDayFilter(final int[] monthDays) {
return new Predicate<DateValue>() {
public boolean apply(DateValue date) {
int nDays = TimeUtils.monthLength(date.year(), date.month());
for (int i = monthDays.length; --i >= 0; ) {
int day = monthDays[i];
if (day < 0) {
day += nDays + 1;
}
if (day == date.day()) {
return true;
}
}
return false;
}
};
}
示例6: weekIntervalFilter
import com.google.ical.values.DateValue; //导入依赖的package包/类
/**
* constructs a filter that accepts only every interval-th week from the week
* containing dtStart.
* @param interval > 0 number of weeks
* @param wkst day of the week that the week starts on.
* @param dtStart non null
*/
static Predicate<DateValue> weekIntervalFilter(
final int interval, final Weekday wkst, final DateValue dtStart) {
return new Predicate<DateValue>() {
DateValue wkStart;
{
// the latest day with day of week wkst on or before dtStart
DTBuilder wkStartB = new DTBuilder(dtStart);
wkStartB.day -=
(7 + Weekday.valueOf(dtStart).javaDayNum - wkst.javaDayNum) % 7;
wkStart = wkStartB.toDate();
}
public boolean apply(DateValue date) {
int daysBetween = TimeUtils.daysBetween(date, wkStart);
if (daysBetween < 0) {
// date must be before dtStart. Shouldn't occur in practice.
daysBetween += (interval * 7 * (1 + daysBetween / (-7 * interval)));
}
int off = (daysBetween / 7) % interval;
return 0 == off;
}
};
}
示例7: byHourFilter
import com.google.ical.values.DateValue; //导入依赖的package包/类
/**
* constructs an hour filter based on a BYHOUR rule.
* @param hours hours of the day in [0, 23]
*/
static Predicate<DateValue> byHourFilter(int[] hours) {
int hoursByBit = 0;
for (int hour : hours) {
hoursByBit |= 1 << hour;
}
if ((hoursByBit & LOW_24_BITS) == LOW_24_BITS) {
return Predicates.alwaysTrue();
}
final int bitField = hoursByBit;
return new Predicate<DateValue>() {
public boolean apply(DateValue date) {
if (!(date instanceof TimeValue)) {
return false;
}
TimeValue tv = (TimeValue) date;
return (bitField & (1 << tv.hour())) != 0;
}
};
}
示例8: byMinuteFilter
import com.google.ical.values.DateValue; //导入依赖的package包/类
/**
* constructs a minute filter based on a BYMINUTE rule.
* @param minutes minutes of the hour in [0, 59]
*/
static Predicate<DateValue> byMinuteFilter(int[] minutes) {
long minutesByBit = 0;
for (int minute : minutes) {
minutesByBit |= 1L << minute;
}
if ((minutesByBit & LOW_60_BITS) == LOW_60_BITS) {
return Predicates.alwaysTrue();
}
final long bitField = minutesByBit;
return new Predicate<DateValue>() {
public boolean apply(DateValue date) {
if (!(date instanceof TimeValue)) {
return false;
}
TimeValue tv = (TimeValue) date;
return (bitField & (1L << tv.minute())) != 0;
}
};
}
示例9: bySecondFilter
import com.google.ical.values.DateValue; //导入依赖的package包/类
/**
* constructs a second filter based on a BYMINUTE rule.
* @param seconds seconds of the minute in [0, 59]
*/
static Predicate<DateValue> bySecondFilter(int[] seconds) {
long secondsByBit = 0;
for (int second : seconds) {
secondsByBit |= 1L << second;
}
if ((secondsByBit & LOW_60_BITS) == LOW_60_BITS) {
return Predicates.alwaysTrue();
}
final long bitField = secondsByBit;
return new Predicate<DateValue>() {
public boolean apply(DateValue date) {
if (!(date instanceof TimeValue)) {
return false;
}
TimeValue tv = (TimeValue) date;
return (bitField & (1L << tv.second())) != 0;
}
};
}
示例10: createRecurrenceIterator
import com.google.ical.values.DateValue; //导入依赖的package包/类
/**
* create a recurrence iterator from an rdate or exdate list.
*/
public static RecurrenceIterator createRecurrenceIterator(RDateList rdates) {
DateValue[] dates = rdates.getDatesUtc();
Arrays.sort(dates);
int k = 0;
for (int i = 1; i < dates.length; ++i) {
if (!dates[i].equals(dates[k])) {
dates[++k] = dates[i];
}
}
if (++k < dates.length) {
DateValue[] uniqueDates = new DateValue[k];
System.arraycopy(dates, 0, uniqueDates, 0, k);
dates = uniqueDates;
}
return new RDateIteratorImpl(dates);
}
示例11: advanceTo
import com.google.ical.values.DateValue; //导入依赖的package包/类
public void advanceTo(DateValue newStart) {
long newStartCmp = DateValueComparison.comparable(newStart);
if (null != pending) {
if (pending.comparable() >= newStartCmp) {
return;
}
pending.advanceTo(newStart);
reattach(pending);
pending = null;
}
// Pull each element off the stack in turn, and advance it.
// Once we reach one we don't need to advance, we're done
while (0 != nInclusionsRemaining && !queue.isEmpty()
&& queue.peek().comparable() < newStartCmp) {
HeapElement el = queue.poll();
el.advanceTo(newStart);
reattach(el);
}
}
示例12: comparable
import com.google.ical.values.DateValue; //导入依赖的package包/类
/**
* reduces a date to a value that can be easily compared to others, consistent
* with {@link com.google.ical.values.DateValueImpl#compareTo}.
*/
static long comparable(DateValue dv) {
long comp = (((((long) dv.year()) << 4) + dv.month()) << 5) + dv.day();
if (dv instanceof TimeValue) {
TimeValue tv = (TimeValue) dv;
// We add 1 to comparable for timed values to make sure that timed
// events are distinct from all-day events, in keeping with
// DateValue.compareTo.
// It would be odd if an all day exclusion matched a midnight event on
// the same day, but not one at another time of day.
return (((((comp << 5) + tv.hour()) << 6) + tv.minute()) << 6)
+ tv.second() + 1;
} else {
return comp << 17;
}
}
示例13: fetchNext
import com.google.ical.values.DateValue; //导入依赖的package包/类
/** calculates and stored the next date in this recurrence. */
private void fetchNext() {
if (null != this.pendingUtc_ || this.done_) {
return;
}
DateValue dUtc = this.generateInstance();
// check the exit condition
if (null != dUtc && this.condition_.apply(dUtc)) {
this.pendingUtc_ = dUtc;
this.yearGenerator_.workDone();
} else {
this.done_ = true;
}
}
示例14: 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;
}
}
示例15: add
import com.google.ical.values.DateValue; //导入依赖的package包/类
public static DateValue add(DateValue d, DateValue dur) {
DTBuilder db = new DTBuilder(d);
db.year += dur.year();
db.month += dur.month();
db.day += dur.day();
if (dur instanceof TimeValue) {
TimeValue tdur = (TimeValue) dur;
db.hour += tdur.hour();
db.minute += tdur.minute();
db.second += tdur.second();
return db.toDateTime();
} else if (d instanceof TimeValue) {
return db.toDateTime();
}
return db.toDate();
}