Package javax.time.calendar

Examples of javax.time.calendar.LocalDate$Rule


     * Converts this date to an ISO-8601 calendar system {@code LocalDate}.
     *
     * @return the equivalent date in the ISO-8601 calendar system, never null
     */
    public LocalDate toLocalDate() {
        LocalDate possible = LocalDate.of(year, month, day);
        if (possible.isBefore(chrono.getCutover())) {
            long julYear1Days = (year - 1) * 365 + (year / 4) + chrono.getDayOfYear(this) - 1;
            return LocalDate.fromModifiedJulianDays(julYear1Days + 0)// TODO
        } else {
            return possible;
        }
View Full Code Here


        private Object readResolve() {
            return INSTANCE;
        }
        @Override
        protected HistoricDate derive(Calendrical calendrical) {
            LocalDate ld = calendrical.get(LocalDate.rule());
            if (ld == null) {
                return null;
            }
//            long epochDays = ld.toModifiedJulianDays() + MJD_TO_historic;
//            return historicDateFromEpochDays((int) epochDays);
View Full Code Here

        private Object readResolve() {
            return INSTANCE;
        }
        @Override
        protected CopticDate derive(Calendrical calendrical) {
            LocalDate ld = calendrical.get(LocalDate.rule());
            if (ld == null) {
                return null;
            }
            long epochDays = ld.toModifiedJulianDays() + MJD_TO_COPTIC;
            return copticDateFromEopchDays((int) epochDays);
        }
View Full Code Here

        /** The time of the cutover. */
        TimeDefinition timeDefinition = TimeDefinition.WALL;

        LocalDateTime toDateTime(int year) {
            adjustToFowards(year);
            LocalDate date;
            if (dayOfMonth == -1) {
                dayOfMonth = month.lengthInDays(year);
                date = LocalDate.date(year, month, dayOfMonth);
                if (dayOfWeek != null) {
                    date = date.with(DateAdjusters.previousOrCurrent(dayOfWeek));
                }
            } else {
                date = LocalDate.date(year, month, dayOfMonth);
                if (dayOfWeek != null) {
                    date = date.with(DateAdjusters.nextOrCurrent(dayOfWeek));
                }
            }
            date = deduplicate(date);
            return LocalDateTime.dateTime(date, time);
        }
View Full Code Here

            return LocalDateTime.dateTime(date, time);
        }

        void adjustToFowards(int year) {
            if (adjustForwards == false && dayOfMonth > 0) {
                LocalDate adjustedDate = LocalDate.date(year, month, dayOfMonth).minusDays(6);
                dayOfMonth = adjustedDate.getDayOfMonth();
                month = adjustedDate.getMonthOfYear();
                adjustForwards = true;
            }
        }
View Full Code Here

     *
     * @param year  the year to create a transition for, not null
     * @return the transition instance, never null
     */
    public ZoneOffsetTransition createTransition(int year) {
        LocalDate date;
        if (dom < 0) {
            date = LocalDate.date(year, month, month.lengthInDays(year) + 1 + dom);
            if (dow != null) {
                date = date.with(DateAdjusters.previousOrCurrent(dow));
            }
        } else {
            date = LocalDate.date(year, month, dom);
            if (dow != null) {
                date = date.with(DateAdjusters.nextOrCurrent(dow));
            }
        }
        LocalDateTime localDT = LocalDateTime.dateTime(date, time);
        OffsetDateTime transition = timeDefinition.createDateTime(localDT, standardOffset, offsetBefore);
        return new ZoneOffsetTransition(transition, offsetAfter);
View Full Code Here

     *
     * @param dateProvider  the date provider to use, not null
     * @return the WeekBasedYear instance, never null
     */
    public static WeekBasedYear weekyear(DateProvider dateProvider) {
        LocalDate date = LocalDate.date(dateProvider);
        return WeekBasedYear.weekyear(computeYear(date).getValue());
    }
View Full Code Here

     *
     * @return the length of this week-based-year in weeks, either 52 or 53
     */
    public int lengthInWeeks() {
        // TODO: optimize
        LocalDate start = LocalDate.date(weekyear, MonthOfYear.JANUARY, 4);
        LocalDate end = LocalDate.date(weekyear, MonthOfYear.DECEMBER, 28);

        long weeksAsLong = (end.toModifiedJulianDays() + (8 - end.getDayOfWeek().getValue()) -
                start.toModifiedJulianDays() + start.getDayOfWeek().getValue() - 1) / 7;

        return MathUtils.safeToInt(weeksAsLong);
    }
View Full Code Here

         * @param savingsBefore  the active savings, not null
         * @return the transition, never null
         */
        ZoneOffsetTransition toTransition(ZoneOffset standardOffset, Period savingsBefore) {
            ZoneOffset offsetAfter = standardOffset.plus(savingAmount);
            LocalDate date;
            if (dayOfMonth == -1) {
                Year yr = Year.isoYear(year);
                date = LocalDate.date(yr, month, month.getLastDayOfMonth(yr));
                if (dayOfWeek != null) {
                    date = date.with(DateAdjusters.previousOrCurrent(dayOfWeek));
                }
            } else {
                date = LocalDate.date(year, month, dayOfMonth);
                if (dayOfWeek != null) {
                    date = date.with(DateAdjusters.nextOrCurrent(dayOfWeek));
                }
            }
            date = deduplicate(date);
            LocalDateTime ldt = deduplicate(LocalDateTime.dateTime(date, time));
            ZoneOffset wallOffset = deduplicate(standardOffset.plus(savingsBefore));
View Full Code Here

     *
     * @param dateProvider  the date provider to use, not null
     * @return the WeekOfWeekBasedYear singleton, never null
     */
    public static WeekOfWeekBasedYear weekOfWeekyear(DateProvider dateProvider) {
        LocalDate date = LocalDate.date(dateProvider);
        Year year = WeekBasedYear.computeYear(date);

        LocalDate yearStart = LocalDate.date(year, MonthOfYear.JANUARY, DayOfMonth.dayOfMonth(4));

        return weekOfWeekyear(MathUtils.safeToInt((date.toModifiedJulianDays() - yearStart.toModifiedJulianDays() +
                yearStart.getDayOfWeek().getValue() - 1) / 7 + 1));
    }
View Full Code Here

TOP

Related Classes of javax.time.calendar.LocalDate$Rule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.