Package javax.time

Examples of javax.time.CalendricalException


        /** {@inheritDoc} */
        @Override
        protected OffsetDateTime handleGap(
                TimeZone zone, ZoneRules rules, ZoneOffsetTransition discontinuity,
                LocalDateTime newDateTime, OffsetDateTime oldDateTime) {
            throw new CalendricalException("Local time " + newDateTime + " does not exist in time zone " +
                    zone + " due to a gap in the local time-line");
        }
View Full Code Here


        /** {@inheritDoc} */
        @Override
        protected OffsetDateTime handleOverlap(
                TimeZone zone, ZoneRules rules, ZoneOffsetTransition discontinuity,
                LocalDateTime newDateTime, OffsetDateTime oldDateTime) {
            throw new CalendricalException("Local time " + newDateTime +
                    " has two matching offsets, " + discontinuity.getOffsetBefore() +
                    " and " + discontinuity.getOffsetAfter() + ", in time zone " + zone);
        }
View Full Code Here

     * @return <code>this</code>, 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</code>, 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 void storeMergedDate(LocalDate date) {
            ISOChronology.checkNotNull(date, "Date must not be null");
            LocalDate storedDate = calendrical.getDate();
            if (storedDate != null && storedDate.equals(date) == false) {
                throw new CalendricalException("Merge resulted in two different dates, " + storedDate + " and " + date);
            }
            calendrical.setDate(date);
            // no need to reset iterator, as store of date should not enable any more calculations
        }
View Full Code Here

         */
        public void storeMergedTime(LocalTime time) {
            ISOChronology.checkNotNull(time, "Time must not be null");
            LocalTime storedTime = calendrical.getTime();
            if (storedTime != null && storedTime.equals(time) == false) {
                throw new CalendricalException("Merge resulted in two different times, " + storedTime + " and " + time);
            }
            calendrical.setTime(time);
            // no need to reset iterator, as store of date should not enable any more calculations
        }
View Full Code Here

         * @throws CalendricalException if the input time does not match a previously stored time
         */
        public void storeMergedTime(LocalTime.Overflow time) {
            ISOChronology.checkNotNull(time, "Time must not be null");
            if (mergedTime != null && mergedTime.equals(time) == false) {
                throw new CalendricalException("Merge resulted in two different times, " + mergedTime + " and " + time);
            }
            storeMergedTime(time.getResultTime());
            mergedTime = time;
            // no need to reset iterator, as store of date should not enable any more calculations
        }
View Full Code Here

            while (iterator.hasNext() && protect < 100) {
                iterator.next().mergeFields(this);
                protect++;
            }
            if (iterator.hasNext()) {
                throw new CalendricalException("Merge fields failed, infinite loop blocked, " +
                        "probably caused by an incorrectly implemented field rule");
            }
        }
View Full Code Here

        ISOChronology.checkNotNull(zoneID, "Time zone ID must not be null");
        if (zoneID.equals("UTC") || zoneID.equals("GMT")) {
            return UTC;
           
        } else if (zoneID.equals("UTCZ") || zoneID.equals("GMTZ")) {
            throw new CalendricalException("Invalid time zone ID: " + zoneID);
           
        } else if (zoneID.startsWith("UTC") || zoneID.startsWith("GMT")) {  // not sure about GMT
            try {
                return timeZone(ZoneOffset.zoneOffset(zoneID.substring(3)));
            } catch (IllegalArgumentException ex) {
                throw new CalendricalException("Invalid time zone ID: " + ex.toString(), ex);
            }
           
        } else {
            int pos = zoneID.indexOf(':');
            ZoneRulesGroup group;
View Full Code Here

     */
    public TimeZone withVersion(String versionID) {
        ISOChronology.checkNotNull(versionID, "Version ID must not be null");
        if (isFixed()) {
            if (versionID.length() > 0) {
                throw new CalendricalException("Fixed time zone does not provide versions");
            }
            return this;
        }
        ZoneRules rules = getGroup().getRules(regionID, versionID)// validates IDs
        if (versionID.equals(this.versionID)) {
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.