当前位置: 首页>>代码示例>>Java>>正文


Java DateValue.year方法代码示例

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


在下文中一共展示了DateValue.year方法的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);
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:25,代码来源:DateTimeIteratorFactory.java

示例2: 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

示例3: 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

示例4: 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

示例5: serialYearGenerator

import com.google.ical.values.DateValue; //导入方法依赖的package包/类
/**
 * constructs a generator that generates years successively counting from the
 * first year passed in.
 * @param interval number of years to advance each step.
 * @param dtStart non null
 * @return the year in dtStart the first time called and interval + last
 *   return value on subsequent calls.
 */
static ThrottledGenerator serialYearGenerator(
        final int interval, final DateValue dtStart) {
    return new ThrottledGenerator() {
        /** the last year seen */
        int year = dtStart.year() - interval;
        int throttle = MAX_YEARS_BETWEEN_INSTANCES;

        @Override
        boolean generate(DTBuilder builder)
                throws IteratorShortCircuitingException {
            // make sure things halt even if the rrule is bad.
            // Rules like
            //   FREQ=YEARLY;BYMONTHDAY=30;BYMONTH=2
            // should halt

            if (--throttle < 0) {
                throw IteratorShortCircuitingException.instance();
            }
            builder.year = year += interval;
            return true;
        }

        @Override
        void workDone() {
            this.throttle = MAX_YEARS_BETWEEN_INSTANCES;
        }

        @Override
        public String toString() {
            return "serialYearGenerator:" + interval;
        }
    };
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:42,代码来源:Generators.java

示例6: byYearGenerator

import com.google.ical.values.DateValue; //导入方法依赖的package包/类
/**
 * constructs a generator that yields the specified years in increasing order.
 */
static Generator byYearGenerator(int[] years, final DateValue dtStart) {
    final int[] uyears = Util.uniquify(years);

    // index into years
    return new Generator() {
        int i;

        {
            while (i < uyears.length && dtStart.year() > uyears[i]) {
                ++i;
            }
        }

        @Override
        boolean generate(DTBuilder builder) {
            if (i >= uyears.length) {
                return false;
            }
            builder.year = uyears[i++];
            return true;
        }

        @Override
        public String toString() {
            return "byYearGenerator";
        }
    };
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:32,代码来源:Generators.java

示例7: byMonthGenerator

import com.google.ical.values.DateValue; //导入方法依赖的package包/类
/**
 * constructs a generator that yields the specified months in increasing order
 * for each year.
 * @param months values in [1-12]
 * @param dtStart non null
 */
static Generator byMonthGenerator(int[] months, final DateValue dtStart) {
    final int[] umonths = Util.uniquify(months);

    return new Generator() {
        int i;
        int year = dtStart.year();

        @Override
        boolean generate(DTBuilder builder) {
            if (year != builder.year) {
                i = 0;
                year = builder.year;
            }
            if (i >= umonths.length) {
                return false;
            }
            builder.month = umonths[i++];
            return true;
        }

        @Override
        public String toString() {
            return "byMonthGenerator:" + Arrays.toString(umonths);
        }
    };
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:33,代码来源:Generators.java

示例8: DTBuilder

import com.google.ical.values.DateValue; //导入方法依赖的package包/类
public DTBuilder(DateValue dv) {
    this.year = dv.year();
    this.month = dv.month();
    this.day = dv.day();
    if (dv instanceof TimeValue) {
        TimeValue tv = (TimeValue) dv;
        this.hour = tv.hour();
        this.minute = tv.minute();
        this.second = tv.second();
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:12,代码来源:DTBuilder.java

示例9: dateValueToLocalDate

import com.google.ical.values.DateValue; //导入方法依赖的package包/类
static LocalDate dateValueToLocalDate(DateValue dvUtc) {
    return new LocalDate(dvUtc.year(), dvUtc.month(), dvUtc.day());
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:4,代码来源:LocalDateIteratorFactory.java

示例10: serialMonthGenerator

import com.google.ical.values.DateValue; //导入方法依赖的package包/类
/**
 * constructs a generator that generates months in the given builder's year
 * successively counting from the first month passed in.
 * @param interval number of months to advance each step.
 * @param dtStart non null.
 * @return the year in dtStart the first time called and interval + last
 *   return value on subsequent calls.
 */
static Generator serialMonthGenerator(
        final int interval, final DateValue dtStart) {
    return new Generator() {
        int year = dtStart.year();
        int month = dtStart.month() - interval;

        {
            while (month < 1) {
                month += 12;
                --year;
            }
        }

        @Override
        boolean generate(DTBuilder builder) {
            int nmonth;
            if (year != builder.year) {
                int monthsBetween = (builder.year - year) * 12 - (month - 1);
                nmonth = ((interval - (monthsBetween % interval)) % interval) + 1;
                if (nmonth > 12) {
                    // don't update year so that the difference calculation above is
                    // correct when this function is reentered with a different year
                    return false;
                }
                year = builder.year;
            } else {
                nmonth = month + interval;
                if (nmonth > 12) {
                    return false;
                }
            }
            month = builder.month = nmonth;
            return true;
        }

        @Override
        public String toString() {
            return "serialMonthGenerator:" + interval;
        }
    };
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:50,代码来源:Generators.java

示例11: serialDayGenerator

import com.google.ical.values.DateValue; //导入方法依赖的package包/类
/**
 * constructs a generator that generates every day in the current month that
 * is an integer multiple of interval days from dtStart.
 */
static Generator serialDayGenerator(
        final int interval, final DateValue dtStart) {
    return new Generator() {
        int year, month, date;
        /** ndays in the last month encountered */
        int nDays;

        {
            // step back one interval
            DTBuilder dtStartMinus1B = new DTBuilder(dtStart);
            dtStartMinus1B.day -= interval;
            DateValue dtStartMinus1 = dtStartMinus1B.toDate();
            year = dtStartMinus1.year();
            month = dtStartMinus1.month();
            date = dtStartMinus1.day();
            nDays = TimeUtils.monthLength(year, month);
        }

        @Override
        boolean generate(DTBuilder builder) {
            int ndate;
            if (year == builder.year && month == builder.month) {
                ndate = date + interval;
                if (ndate > nDays) {
                    return false;
                }
            } else {
                nDays = TimeUtils.monthLength(builder.year, builder.month);
                if (interval != 1) {
                    // Calculate the number of days between the first of the new
                    // month andthe old date and extend it to make it an integer
                    // multiple of interval
                    int daysBetween = TimeUtils.daysBetween(
                            new DateValueImpl(builder.year, builder.month, 1),
                            new DateValueImpl(year, month, date));
                    ndate = ((interval - (daysBetween % interval)) % interval) + 1;
                    if (ndate > nDays) {
                        // need to early out without updating year or month so that the
                        // next time we enter, with a different month, the daysBetween
                        // call above compares against the proper last date
                        return false;
                    }
                } else {
                    ndate = 1;
                }
                year = builder.year;
                month = builder.month;
            }
            date = builder.day = ndate;
            return true;
        }

        @Override
        public String toString() {
            return "serialDayGenerator:" + interval;
        }
    };
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:63,代码来源:Generators.java

示例12: serialHourGenerator

import com.google.ical.values.DateValue; //导入方法依赖的package包/类
/**
 * constructs a generator that generates hours in the given builder's day
 * successively counting from the first hour passed in.
 * @param interval number of hours to advance each step.
 * @param dtStart non null.
 * @return the day in dtStart the first time called and interval + last
 *   return value on subsequent calls.
 */
static Generator serialHourGenerator(
        final int interval, final DateValue dtStart) {

    return new Generator() {
        int hour = ((dtStart instanceof TimeValue)
                ? ((TimeValue) dtStart).hour() : 0) - interval;
        int day = dtStart.day();
        int month = dtStart.month();
        int year = dtStart.year();

        @Override
        boolean generate(DTBuilder builder) {
            int nhour;
            if (day != builder.day || month != builder.month
                    || year != builder.year) {
                int hoursBetween = daysBetween(
                        builder, year, month, day) * 24 - hour;
                nhour = ((interval - (hoursBetween % interval)) % interval);
                if (nhour > 23) {
                    // Don't update day so that the difference calculation above is
                    // correct when this function is reentered with a different day
                    return false;
                }
                day = builder.day;
                month = builder.month;
                year = builder.year;
            } else {
                nhour = hour + interval;
                if (nhour > 23) {
                    return false;
                }
            }
            hour = builder.hour = nhour;
            return true;
        }

        @Override
        public String toString() {
            return "serialHourGenerator:" + interval;
        }
    };
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:51,代码来源:Generators.java

示例13: serialMinuteGenerator

import com.google.ical.values.DateValue; //导入方法依赖的package包/类
/**
 * constructs a generator that generates minutes in the given builder's hour
 * successively counting from the first minute passed in.
 * @param interval number of minutes to advance each step.
 * @param dtStart non null.
 * @return the day in dtStart the first time called and interval + last
 *   return value on subsequent calls.
 */
static Generator serialMinuteGenerator(
        final int interval, final DateValue dtStart) {

    return new Generator() {
        int minute = (dtStart instanceof TimeValue
                ? ((TimeValue) dtStart).minute() : 0) - interval;
        int hour = dtStart instanceof TimeValue
                ? ((TimeValue) dtStart).hour() : 0;
        int day = dtStart.day();
        int month = dtStart.month();
        int year = dtStart.year();

        @Override
        boolean generate(DTBuilder builder) {
            int nminute;
            if (hour != builder.hour || day != builder.day || month != builder.month
                    || year != builder.year) {
                int minutesBetween = (daysBetween(
                        builder, year, month, day) * 24 + builder.hour - hour) * 60
                        - minute;
                nminute = ((interval - (minutesBetween % interval)) % interval);
                if (nminute > 59) {
                    // Don't update day so that the difference calculation above is
                    // correct when this function is reentered with a different day
                    return false;
                }
                hour = builder.hour;
                day = builder.day;
                month = builder.month;
                year = builder.year;
            } else {
                nminute = minute + interval;
                if (nminute > 59) {
                    return false;
                }
            }
            minute = builder.minute = nminute;
            return true;
        }

        @Override
        public String toString() {
            return "serialMinuteGenerator:" + interval;
        }
    };
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:55,代码来源:Generators.java

示例14: serialSecondGenerator

import com.google.ical.values.DateValue; //导入方法依赖的package包/类
/**
 * constructs a generator that generates seconds in the given builder's minute
 * successively counting from the first second passed in.
 * @param interval number of seconds to advance each step.
 * @param dtStart non null.
 * @return the day in dtStart the first time called and interval + last
 *   return value on subsequent calls.
 */
static Generator serialSecondGenerator(
        final int interval, final DateValue dtStart) {

    return new Generator() {
        int second = (dtStart instanceof TimeValue
                ? ((TimeValue) dtStart).second() : 0) - interval;
        int minute = dtStart instanceof TimeValue
                ? ((TimeValue) dtStart).minute() : 0;
        int hour = dtStart instanceof TimeValue
                ? ((TimeValue) dtStart).hour() : 0;
        int day = dtStart.day();
        int month = dtStart.month();
        int year = dtStart.year();

        @Override
        boolean generate(DTBuilder builder) {
            int nsecond;
            if (minute != builder.minute || hour != builder.hour
                    || day != builder.day || month != builder.month
                    || year != builder.year) {
                int secondsBetween = ((daysBetween(
                        builder, year, month, day) * 24 + builder.hour - hour) * 60
                        + builder.minute - minute) * 60 - second;
                nsecond = ((interval - (secondsBetween % interval)) % interval);
                if (nsecond > 59) {
                    // Don't update day so that the difference calculation above is
                    // correct when this function is reentered with a different day
                    return false;
                }
                minute = builder.minute;
                hour = builder.hour;
                day = builder.day;
                month = builder.month;
                year = builder.year;
            } else {
                nsecond = second + interval;
                if (nsecond > 59) {
                    return false;
                }
            }
            second = builder.second = nsecond;
            return true;
        }

        @Override
        public String toString() {
            return "serialSecondGenerator:" + interval;
        }
    };
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:59,代码来源:Generators.java

示例15: byYearDayGenerator

import com.google.ical.values.DateValue; //导入方法依赖的package包/类
/**
 * constructs a day generator that generates dates in the current month that
 * fall on one of the given days of the year.
 * @param yearDays elements in [-366,366] != 0
 */
static Generator byYearDayGenerator(int[] yearDays, final DateValue dtStart) {
    final int[] uYearDays = Util.uniquify(yearDays);

    return new Generator() {
        int year = dtStart.year();
        int month = dtStart.month();
        int[] dates;
        int i = 0;

        {
            checkMonth();
        }

        void checkMonth() {
            // now, calculate the first week of the month
            int doyOfMonth1 = TimeUtils.dayOfYear(year, month, 1);
            int nDays = TimeUtils.monthLength(year, month);
            int nYearDays = TimeUtils.yearLength(year);
            IntSet udates = new IntSet();
            for (int j = 0; j < uYearDays.length; j++) {
                int yearDay = uYearDays[j];
                if (yearDay < 0) {
                    yearDay += nYearDays + 1;
                }
                int date = yearDay - doyOfMonth1;
                if (date >= 1 && date <= nDays) {
                    udates.add(date);
                }
            }
            dates = udates.toIntArray();
        }

        @Override
        boolean generate(DTBuilder builder) {
            if (year != builder.year || month != builder.month) {
                year = builder.year;
                month = builder.month;

                checkMonth();

                i = 0;
            }
            if (i >= dates.length) {
                return false;
            }
            builder.day = dates[i++];
            return true;
        }

        @Override
        public String toString() {
            return "byYearDayGenerator";
        }
    };
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:61,代码来源:Generators.java


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