Package javax.time

Examples of javax.time.CalendricalException


     */
    public TimeZone withLatestVersionValidFor(OffsetDateTime dateTime) {
        ISOChronology.checkNotNull(dateTime, "OffsetDateTime must not be null");
        if (isFixed()) {
            if (getRules().getOffset(dateTime).equals(dateTime.getOffset()) == false) {
                throw new CalendricalException("Fixed time zone " + getID() + " is invalid for date-time " + dateTime);
            }
            return this;
        }
        return withVersion(getGroup().getLatestVersionIDValidFor(regionID, dateTime));
    }
View Full Code Here


     * @throws CalendricalException if the time zone is fixed
     * @throws CalendricalException if the group ID cannot be found
     */
    public ZoneRulesGroup getGroup() {
        if (isFixed()) {
            throw new CalendricalException("Fixed time zone is not provided by a group");
        }
        return ZoneRulesGroup.getGroup(groupID);
    }
View Full Code Here

     */
    public ZoneRules getRulesValidFor(OffsetDateTime dateTime) {
        ISOChronology.checkNotNull(dateTime, "OffsetDateTime must not be null");
        if (isFixed()) {
            if (getRules().getOffset(dateTime).equals(dateTime.getOffset()) == false) {
                throw new CalendricalException("Fixed time zone " + getID() + " is invalid for date-time " + dateTime);
            }
            return ZoneRules.fixed(getRules().getOffset(dateTime));
        }
        ZoneRulesGroup group = ZoneRulesGroup.getGroup(groupID);
        return group.getRulesValidFor(regionID, versionID, dateTime);
View Full Code Here

            handleGap(zone, rules, discontinuity, newDateTime, oldDateTime != null ? oldDateTime.toOffsetDateTime() : null) :
            handleOverlap(zone, rules, discontinuity, newDateTime, oldDateTime != null ? oldDateTime.toOffsetDateTime() : null);
       
        // validate the result
        if (result == null) {
            throw new CalendricalException(
                    "ZoneResolver implementation must not return null: " + getClass().getName());
        }
        if (zone.isValidFor(result) == false) {
            throw new CalendricalException(
                    "ZoneResolver implementation must return a valid date-time and offset for the zone: " + getClass().getName());
        }
        return result;
    }
View Full Code Here

     * @return the local time, never null
     * @throws CalendricalException if the nanos of day value is invalid
     */
    public static LocalTime fromNanoOfDay(long nanoOfDay) {
        if (nanoOfDay < 0) {
            throw new CalendricalException("Cannot create LocalTime from nanos of day as value " +
                    nanoOfDay + " must not be negative");
        }
        if (nanoOfDay >= NANOS_PER_DAY) {
            throw new CalendricalException("Cannot create LocalTime from nanos of day as value " +
                    nanoOfDay + " must be less than " + NANOS_PER_DAY);
        }
        int hours = (int) (nanoOfDay / NANOS_PER_HOUR);
        nanoOfDay -= hours * NANOS_PER_HOUR;
        int minutes = (int) (nanoOfDay / NANOS_PER_MINUTE);
View Full Code Here

     * @return {@code this}, never null
     * @throws CalendricalException if the period cannot be converted as it contains years/months/days
     */
    public Duration toDuration() {
        if ((years | months | days) > 0) {
            throw new CalendricalException("Unable to convert period to duration as years/months/days are present: " + this);
        }
        long secs = (hours * 60L + minutes) * 60L + seconds;  // will not overflow
        return Duration.seconds(secs, nanos);
    }
View Full Code Here

     * @return {@code this}, never null
     * @throws CalendricalException if the period cannot be converted as it contains years/months/days
     */
    public Duration toDurationWith24HourDays() {
        if ((years | months) > 0) {
            throw new CalendricalException("Unable to convert period to duration as years/months are present: " + this);
        }
        long secs = ((days * 24L + hours) * 60L + minutes) * 60L + seconds;  // will not overflow
        return Duration.seconds(secs, nanos);
    }
View Full Code Here

    public PeriodField toEquivalentPeriod(PeriodUnit requiredUnit) {
        PeriodField equivalent = unit.getEquivalentPeriod(requiredUnit);
        if (equivalent != null) {
            return equivalent.multipliedBy(amount);
        }
        throw new CalendricalException("Unable to convert " + getUnit() + " to " + requiredUnit);
    }
View Full Code Here

            PeriodField equivalent = unit.getEquivalentPeriod(requiredUnit);
            if (equivalent != null) {
                return equivalent.multipliedBy(amount);
            }
        }
        throw new CalendricalException("Unable to convert " + getUnit() + " to any requested unit: " + Arrays.toString(requiredUnits));
    }
View Full Code Here

        }
        equivalent = unit.getEquivalentPeriod(ISOChronology.periodNanos());
        if (equivalent != null) {
            return equivalent.multipliedBy(amount).toEstimatedDuration();
        }
        throw new CalendricalException("Unable to convert " + getUnit() + " to a Duration");
    }
View Full Code Here

TOP

Related Classes of javax.time.CalendricalException

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.