• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DateValue类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.ical.values.DateValue的典型用法代码示例。如果您正苦于以下问题:Java DateValue类的具体用法?Java DateValue怎么用?Java DateValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DateValue类属于com.google.ical.values包,在下文中一共展示了DateValue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:25,代码来源:DateTimeIteratorFactory.java


示例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();
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:22,代码来源:DateIteratorFactory.java


示例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);
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:20,代码来源:DateIteratorFactory.java


示例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"));
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:25,代码来源:ZonedDateTimeIteratorFactory.java


示例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;
        }
    };
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:22,代码来源:Filters.java


示例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;
        }
    };
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:32,代码来源:Filters.java


示例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;
        }
    };
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:24,代码来源:Filters.java


示例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;
        }
    };
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:24,代码来源:Filters.java


示例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;
        }
    };
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:24,代码来源:Filters.java


示例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);
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:20,代码来源:RecurrenceIteratorFactory.java


示例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);
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:21,代码来源:CompoundIteratorImpl.java


示例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;
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:21,代码来源:DateValueComparison.java


示例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;
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:17,代码来源:RRuleIteratorImpl.java


示例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;
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:21,代码来源:RRuleIteratorImpl.java


示例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();
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:17,代码来源:TimeUtils.java


示例16: compareTo

import com.google.ical.values.DateValue; //导入依赖的package包/类
/**
 * behavior undefined unless normalized.
 * If you're not sure whether it's appropriate to use this method, use
 * <code>toDateValue().compareTo(dv)</code> instead.
 */
public int compareTo(DateValue dv) {
    long dvComparable =
            (((((long) dv.year()) << 4) + dv.month()) << 5) + dv.day();
    long dtbComparable =
            ((((long) year << 4) + month << 5)) + day;
    if (dv instanceof TimeValue) {
        TimeValue tv = (TimeValue) dv;
        dvComparable = (((((dvComparable << 5) + tv.hour()) << 6) + tv.minute())
                << 6) + tv.second();
        dtbComparable = (((((dtbComparable << 5) + hour) << 6) + minute)
                << 6) + second;
    }
    long delta = dtbComparable - dvComparable;
    return delta < 0 ? -1 : delta == 0 ? 0 : 1;
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:21,代码来源:DTBuilder.java


示例17: testSerialHourGeneratorGivenDate

import com.google.ical.values.DateValue; //导入依赖的package包/类
public void testSerialHourGeneratorGivenDate() throws Exception {
    DateValue dtStart = new DateValueImpl(2011, 8, 8);
    Generator g = Generators.serialHourGenerator(7, dtStart);
    DTBuilder b = new DTBuilder(dtStart);
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 0:0:0", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 7:0:0", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 14:0:0", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 21:0:0", b.toString());
    assertFalse(g.generate(b));
    assertEquals("2011-8-8 21:0:0", b.toString());
    ++b.day;
    assertTrue(g.generate(b));
    assertEquals("2011-8-9 4:0:0", b.toString());
    b.day += 2;
    assertTrue(g.generate(b));
    assertEquals("2011-8-11 5:0:0", b.toString());
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:22,代码来源:GeneratorsTest.java


示例18: testSerialHourGeneratorGivenTime

import com.google.ical.values.DateValue; //导入依赖的package包/类
public void testSerialHourGeneratorGivenTime() throws Exception {
    DateValue dtStart = new DateTimeValueImpl(2011, 8, 8, 1, 25, 30);
    Generator g = Generators.serialHourGenerator(7, dtStart);
    DTBuilder b = new DTBuilder(dtStart);
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 1:25:30", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 8:25:30", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 15:25:30", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 22:25:30", b.toString());
    assertFalse(g.generate(b));
    assertEquals("2011-8-8 22:25:30", b.toString());
    ++b.day;
    assertTrue(g.generate(b));
    assertEquals("2011-8-9 5:25:30", b.toString());
    b.day += 2;
    assertTrue(g.generate(b));
    assertEquals("2011-8-11 6:25:30", b.toString());
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:22,代码来源:GeneratorsTest.java


示例19: testSerialHourGeneratorRolledBack

import com.google.ical.values.DateValue; //导入依赖的package包/类
public void testSerialHourGeneratorRolledBack() throws Exception {
    DateValue dtStart = new DateTimeValueImpl(2011, 8, 8, 1, 25, 30);
    Generator g = Generators.serialHourGenerator(7, dtStart);
    DTBuilder b = new DTBuilder(new DateTimeValueImpl(2011, 8, 1, 0, 29, 50));
    assertTrue(g.generate(b));
    assertEquals("2011-8-1 1:29:50", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-1 8:29:50", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-1 15:29:50", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-1 22:29:50", b.toString());
    assertFalse(g.generate(b));
    assertEquals("2011-8-1 22:29:50", b.toString());
    ++b.day;
    assertTrue(g.generate(b));
    assertEquals("2011-8-2 5:29:50", b.toString());
    b.day += 2;
    assertTrue(g.generate(b));
    assertEquals("2011-8-4 6:29:50", b.toString());
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:22,代码来源:GeneratorsTest.java


示例20: testByHourGeneratorGivenDate

import com.google.ical.values.DateValue; //导入依赖的package包/类
public void testByHourGeneratorGivenDate() throws Exception {
    DateValue dtStart = new DateValueImpl(2011, 8, 8);
    Generator g = Generators.byHourGenerator(new int[]{3, 9, 11}, dtStart);
    DTBuilder b = new DTBuilder(dtStart);
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 3:0:0", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 9:0:0", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-8 11:0:0", b.toString());
    assertFalse(g.generate(b));
    assertEquals("2011-8-8 11:0:0", b.toString());
    ++b.day;
    assertTrue(g.generate(b));
    assertEquals("2011-8-9 3:0:0", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-9 9:0:0", b.toString());
    assertTrue(g.generate(b));
    assertEquals("2011-8-9 11:0:0", b.toString());
    ++b.month;
    assertTrue(g.generate(b));
    assertEquals("2011-9-9 3:0:0", b.toString());
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:24,代码来源:GeneratorsTest.java



注:本文中的com.google.ical.values.DateValue类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DefaultDocumentEvent类代码示例发布时间:2022-05-22
下一篇:
Java SortOrder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap