Package javax.time.calendar.zone.ZoneRules

Examples of javax.time.calendar.zone.ZoneRules.OffsetInfo


            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() ?
            handleGap(zone, rules, discontinuity, newDateTime, oldDateTime != null ? oldDateTime.toOffsetDateTime() : null) :
            handleOverlap(zone, rules, discontinuity, newDateTime, oldDateTime != null ? oldDateTime.toOffsetDateTime() : null);
       
        // validate the result
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");
            }
            throw new CalendarConversionException("The offset in the date-time " + dateTime +
                    " is invalid for time zone " + zone);
View Full Code Here

     * @return a new updated ZonedDateTime, never null
     * @throws CalendricalException if no rules can be found for the zone
     * @throws CalendricalException if no rules are valid for this date-time
     */
    public ZonedDateTime withEarlierOffsetAtOverlap() {
        OffsetInfo info = getApplicableRules().getOffsetInfo(toLocalDateTime());
        if (info.isTransition()) {
            ZoneOffset offset = info.getTransition().getOffsetBefore();
            if (offset.equals(getOffset()) == false) {
                OffsetDateTime newDT = dateTime.withOffsetSameLocal(offset);
                return new ZonedDateTime(newDT, zone);
            }
        }
View Full Code Here

     * @return a new updated ZonedDateTime, never null
     * @throws CalendricalException if no rules can be found for the zone
     * @throws CalendricalException if no rules are valid for this date-time
     */
    public ZonedDateTime withLaterOffsetAtOverlap() {
        OffsetInfo info = getApplicableRules().getOffsetInfo(toLocalDateTime());
        if (info.isTransition()) {
            ZoneOffset offset = info.getTransition().getOffsetAfter();
            if (offset.equals(getOffset()) == false) {
                OffsetDateTime newDT = dateTime.withOffsetSameLocal(offset);
                return new ZonedDateTime(newDT, 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");
            }
            throw new CalendarConversionException("The offset in the date-time " + dateTime +
                    " is invalid for time zone " + zone);
View Full Code Here

     * @return a new updated ZonedDateTime, never null
     * @throws CalendricalException if no rules can be found for the zone
     * @throws CalendricalException if no rules are valid for this date-time
     */
    public ZonedDateTime withEarlierOffsetAtOverlap() {
        OffsetInfo info = getApplicableRules().getOffsetInfo(toLocalDateTime());
        if (info.isDiscontinuity()) {
            ZoneOffset offset = info.getDiscontinuity().getOffsetBefore();
            if (offset.equals(getOffset()) == false) {
                OffsetDateTime newDT = dateTime.withOffsetSameLocal(offset);
                return new ZonedDateTime(newDT, zone);
            }
        }
View Full Code Here

     * @return a new updated ZonedDateTime, never null
     * @throws CalendricalException if no rules can be found for the zone
     * @throws CalendricalException if no rules are valid for this date-time
     */
    public ZonedDateTime withLaterOffsetAtOverlap() {
        OffsetInfo info = getApplicableRules().getOffsetInfo(toLocalDateTime());
        if (info.isDiscontinuity()) {
            ZoneOffset offset = info.getDiscontinuity().getOffsetAfter();
            if (offset.equals(getOffset()) == false) {
                OffsetDateTime newDT = dateTime.withOffsetSameLocal(offset);
                return new ZonedDateTime(newDT, zone);
            }
        }
View Full Code Here

TOP

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

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.