Package javax.time.period

Examples of javax.time.period.Period


     * @return a {@code LocalDateTime} with the period subtracted, never null
     * @throws CalendricalException if the provider contains time period units
     * @throws CalendricalException if the result exceeds the supported date range
     */
    public LocalDate minus(PeriodProvider periodProvider) {
        Period period = Period.from(periodProvider)// TODO: overflows long->int PeriodFields
        if ((period.getHours() | period.getMinutes() | period.getSeconds() | period.getNanos()) != 0) {
            throw new CalendricalException("Unable to subtract from date as the period contains time units");
        }
        // TODO: calculate in one go
        return minusYears(period.getYears()).minusMonths(period.getMonths()).minusDays(period.getDays());
    }
View Full Code Here


     * @param periodProvider  the period to add, not null
     * @return a new updated Year, never null
     * @throws CalendricalException if the result exceeds the supported year range
     */
    public Year plus(PeriodProvider periodProvider) {
        Period period = Period.from(periodProvider);
        return plusYears(period.getYears());
    }
View Full Code Here

     * @param periodProvider  the period to subtract, not null
     * @return a new updated Year, never null
     * @throws CalendricalException if the result exceeds the supported year range
     */
    public Year minus(PeriodProvider periodProvider) {
        Period period = Period.from(periodProvider);
        return minusYears(period.getYears());
    }
View Full Code Here

     * @param periodProvider  the period to subtract, not null
     * @return a new updated LocalDate, never null
     * @throws CalendricalException if the result exceeds the supported date range
     */
    public LocalDate minus(PeriodProvider periodProvider) {
        Period period = Period.period(periodProvider);
        return minusYears(period.getYears()).minusMonths(period.getMonths()).minusDays(period.getDays());
    }
View Full Code Here

     * @param periodProvider  the period to add, not null
     * @return a new updated Year, never null
     * @throws CalendricalException if the result exceeds the supported year range
     */
    public Year plus(PeriodProvider periodProvider) {
        Period period = Period.period(periodProvider);
        return plusYears(period.getYears());
    }
View Full Code Here

     * @param periodProvider  the period to subtract, not null
     * @return a new updated Year, never null
     * @throws CalendricalException if the result exceeds the supported year range
     */
    public Year minus(PeriodProvider periodProvider) {
        Period period = Period.period(periodProvider);
        return minusYears(period.getYears());
    }
View Full Code Here

        List<ZoneOffsetTransitionRule> lastTransitionRuleList = new ArrayList<ZoneOffsetTransitionRule>(2);
       
        // initialize the standard offset calculation
        TZWindow firstWindow = windowList.get(0);
        ZoneOffset standardOffset = firstWindow.standardOffset;
        Period savings = Period.ZERO;
        if (firstWindow.fixedSavingAmount != null) {
            savings = firstWindow.fixedSavingAmount;
        }
        ZoneOffset firstWallOffset = deduplicate(standardOffset.plus(savings));
        OffsetDateTime windowStart = deduplicate(OffsetDateTime.dateTime(Year.MIN_YEAR, 1, 1, 0, 0, firstWallOffset));
       
        // build the windows and rules to interesting data
        for (TZWindow window : windowList) {
            // tidy the state
            window.tidy(windowStart.getYear());
           
            // calculate effective savings at the start of the window
            Period effectiveSavings = window.fixedSavingAmount;
            if (effectiveSavings == null) {
                // apply rules from this window together with the standard offset and
                // savings from the last window to find the savings amount applicable
                // at start of this window
                effectiveSavings = Period.ZERO;
View Full Code Here

     * @param periodProvider  the period to add, not null
     * @return a {@code LocalTime} with the period added, never null
     * @throws CalendricalException if the provider contains date period units
     */
    public LocalTime plus(PeriodProvider periodProvider) {
        Period period = Period.from(periodProvider)// TODO: overflows long->int PeriodFields
        if ((period.getYears() | period.getMonths() | period.getDays()) != 0) {
            throw new CalendricalException("Unable to add to date as the period contains date units");
        }
        long totNanos = period.getNanos() % NANOS_PER_DAY +                    //   max  86400000000000
                (period.getSeconds() % SECONDS_PER_DAY) * NANOS_PER_SECOND +   //   max  86400000000000
                (period.getMinutes() % MINUTES_PER_DAY) * NANOS_PER_MINUTE +   //   max  86400000000000
                (period.getHours() % HOURS_PER_DAY) * NANOS_PER_HOUR;          //   max  86400000000000
        return plusNanos(totNanos);
    }
View Full Code Here

     * @param periodProvider  the period to subtract, not null
     * @return a {@code LocalTime} with the period subtracted, never null
     * @throws CalendricalException if the provider contains date period units
     */
    public LocalTime minus(PeriodProvider periodProvider) {
        Period period = Period.from(periodProvider)// TODO: overflows long->int PeriodFields
        if ((period.getYears() | period.getMonths() | period.getDays()) != 0) {
            throw new CalendricalException("Unable to add to date as the period contains date units");
        }
        long totNanos = period.getNanos() % NANOS_PER_DAY +                    //   max  86400000000000
                (period.getSeconds() % SECONDS_PER_DAY) * NANOS_PER_SECOND +   //   max  86400000000000
                (period.getMinutes() % MINUTES_PER_DAY) * NANOS_PER_MINUTE +   //   max  86400000000000
                (period.getHours() % HOURS_PER_DAY) * NANOS_PER_HOUR;          //   max  86400000000000
        return minusNanos(totNanos);
    }
View Full Code Here

        List<ZoneOffsetTransitionRule> lastTransitionRuleList = new ArrayList<ZoneOffsetTransitionRule>(2);
       
        // initialize the standard offset calculation
        TZWindow firstWindow = windowList.get(0);
        ZoneOffset standardOffset = firstWindow.standardOffset;
        Period savings = Period.ZERO;
        if (firstWindow.fixedSavingAmount != null) {
            savings = firstWindow.fixedSavingAmount;
        }
        ZoneOffset firstWallOffset = deduplicate(standardOffset.plus(savings));
        OffsetDateTime windowStart = deduplicate(OffsetDateTime.of(Year.MIN_YEAR, 1, 1, 0, 0, firstWallOffset));
       
        // build the windows and rules to interesting data
        for (TZWindow window : windowList) {
            // tidy the state
            window.tidy(windowStart.getYear());
           
            // calculate effective savings at the start of the window
            Period effectiveSavings = window.fixedSavingAmount;
            if (effectiveSavings == null) {
                // apply rules from this window together with the standard offset and
                // savings from the last window to find the savings amount applicable
                // at start of this window
                effectiveSavings = Period.ZERO;
View Full Code Here

TOP

Related Classes of javax.time.period.Period

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.