Package javax.time.calendar.zone

Examples of javax.time.calendar.zone.ZoneRules


            String versionID = "";
            if (pos >= 0) {
                versionID = zoneID.substring(pos + 1);
                zoneID = zoneID.substring(0, pos);
            }
            ZoneRules rules = group.getRules(zoneID, versionID)// validates IDs
            return new TimeZone(group.getID(), zoneID, versionID, rules);
        }
    }
View Full Code Here


        ISOChronology.checkNotNull(offset, "ZoneOffset must not be null");
        if (offset == ZoneOffset.UTC) {
            return UTC;
        }
        String id = "UTC" + offset.getID();
        ZoneRules zoneRules = ZoneRules.fixed(offset);
        return new TimeZone("", id, "", zoneRules);
    }
View Full Code Here

            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)) {
            return this;
        }
        return new TimeZone(groupID, regionID, versionID, rules);
    }
View Full Code Here

        // fixed rules always in transient field
        if (rules != null) {
            return rules;
        }
        ZoneRulesGroup group = ZoneRulesGroup.getGroup(groupID);
        ZoneRules r = group.getRules(regionID, versionID);
        if (versionID.length() > 0) {
            rules = r;
        }
        return r;
    }
View Full Code Here

            TimeZone zone,
            LocalDateTime newDateTime,
            ZonedDateTime oldDateTime) {
       
        // ensure rules used are appropriate if zone has a floating version
        ZoneRules rules = (oldDateTime != null ? oldDateTime.getApplicableRules() : zone.getRules());
       
        OffsetInfo info = rules.getOffsetInfo(newDateTime);
        if (info.isTransition() == false) {
            return OffsetDateTime.from(newDateTime, info.getOffset());
        }
        ZoneOffsetTransition discontinuity = info.getTransition();
        OffsetDateTime result = discontinuity.isGap() ?
View Full Code Here

     */
    public static ZonedDateTime of(OffsetDateTime dateTime, TimeZone zone) {
        ISOChronology.checkNotNull(dateTime, "OffsetDateTime must not be null");
        ISOChronology.checkNotNull(zone, "TimeZone must not be null");
        ZoneOffset inputOffset = dateTime.getOffset();
        ZoneRules rules = zone.getRules()// latest rules version
        OffsetInfo info = rules.getOffsetInfo(dateTime.toLocalDateTime());
        if (info.isValidOffset(inputOffset) == false) {
            if (info.isTransition() && info.getTransition().isGap()) {
                throw new CalendarConversionException("The local time " + dateTime.toLocalDateTime() +
                        " does not exist in time zone " + zone + " due to a daylight savings gap");
            }
View Full Code Here

     * @throws CalendricalException if the result exceeds the supported range
     */
    public static ZonedDateTime fromInstant(InstantProvider instantProvider, TimeZone zone) {
        Instant instant = Instant.from(instantProvider);
        ISOChronology.checkNotNull(zone, "TimeZone must not be null");
        ZoneRules rules = zone.getRules()// latest rules version
        OffsetDateTime offsetDT = OffsetDateTime.fromInstant(instant, rules.getOffset(instant));
        return new ZonedDateTime(offsetDT, zone);
    }
View Full Code Here

     * @throws CalendricalException if the result exceeds the supported range
     */
    public static ZonedDateTime fromInstant(OffsetDateTime dateTime, TimeZone zone) {
        ISOChronology.checkNotNull(dateTime, "OffsetDateTime must not be null");
        ISOChronology.checkNotNull(zone, "TimeZone must not be null");
        ZoneRules rules = zone.getRules()// latest rules version
        if (rules.isValidDateTime(dateTime) == false) {
            ZoneOffset offsetForInstant = rules.getOffset(dateTime);
            dateTime = dateTime.withOffsetSameInstant(offsetForInstant);
        }
        return new ZonedDateTime(dateTime, zone);
    }
View Full Code Here

     */
    public static ZonedDateTime dateTime(OffsetDateTime dateTime, TimeZone zone) {
        ISOChronology.checkNotNull(dateTime, "OffsetDateTime must not be null");
        ISOChronology.checkNotNull(zone, "TimeZone must not be null");
        ZoneOffset inputOffset = dateTime.getOffset();
        ZoneRules rules = zone.getRules()// latest rules version
        OffsetInfo info = rules.getOffsetInfo(dateTime.toLocalDateTime());
        if (info.isValidOffset(inputOffset) == false) {
            if (info.isDiscontinuity() && info.getDiscontinuity().isGap()) {
                throw new CalendarConversionException("The local time " + dateTime.toLocalDateTime() +
                        " does not exist in time zone " + zone + " due to a daylight savings gap");
            }
View Full Code Here

     * @throws CalendricalException if the result exceeds the supported range
     */
    public static ZonedDateTime fromInstant(InstantProvider instantProvider, TimeZone zone) {
        Instant instant = Instant.instant(instantProvider);
        ISOChronology.checkNotNull(zone, "TimeZone must not be null");
        ZoneRules rules = zone.getRules()// latest rules version
        OffsetDateTime offsetDT = OffsetDateTime.fromInstant(instant, rules.getOffset(instant));
        return new ZonedDateTime(offsetDT, zone);
    }
View Full Code Here

TOP

Related Classes of javax.time.calendar.zone.ZoneRules

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.