Java Code Examples for java.time.zone.ZoneOffsetTransition#getDateTimeAfter()

The following examples show how to use java.time.zone.ZoneOffsetTransition#getDateTimeAfter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalDate.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a zoned date-time from this date at the earliest valid time according
 * to the rules in the time-zone.
 * <p>
 * Time-zone rules, such as daylight savings, mean that not every local date-time
 * is valid for the specified zone, thus the local date-time may not be midnight.
 * <p>
 * In most cases, there is only one valid offset for a local date-time.
 * In the case of an overlap, there are two valid offsets, and the earlier one is used,
 * corresponding to the first occurrence of midnight on the date.
 * In the case of a gap, the zoned date-time will represent the instant just after the gap.
 * <p>
 * If the zone ID is a {@link ZoneOffset}, then the result always has a time of midnight.
 * <p>
 * To convert to a specific time in a given time-zone call {@link #atTime(LocalTime)}
 * followed by {@link LocalDateTime#atZone(ZoneId)}.
 *
 * @param zone  the zone ID to use, not null
 * @return the zoned date-time formed from this date and the earliest valid time for the zone, not null
 */
public ZonedDateTime atStartOfDay(ZoneId zone) {
    Objects.requireNonNull(zone, "zone");
    // need to handle case where there is a gap from 11:30 to 00:30
    // standard ZDT factory would result in 01:00 rather than 00:30
    LocalDateTime ldt = atTime(LocalTime.MIDNIGHT);
    if (zone instanceof ZoneOffset == false) {
        ZoneRules rules = zone.getRules();
        ZoneOffsetTransition trans = rules.getTransition(ldt);
        if (trans != null && trans.isGap()) {
            ldt = trans.getDateTimeAfter();
        }
    }
    return ZonedDateTime.of(ldt, zone);
}
 
Example 2
Source File: LocalDate.java    From j2objc with Apache License 2.0 3 votes vote down vote up
/**
 * Returns a zoned date-time from this date at the earliest valid time according
 * to the rules in the time-zone.
 * <p>
 * Time-zone rules, such as daylight savings, mean that not every local date-time
 * is valid for the specified zone, thus the local date-time may not be midnight.
 * <p>
 * In most cases, there is only one valid offset for a local date-time.
 * In the case of an overlap, there are two valid offsets, and the earlier one is used,
 * corresponding to the first occurrence of midnight on the date.
 * In the case of a gap, the zoned date-time will represent the instant just after the gap.
 * <p>
 * If the zone ID is a {@link ZoneOffset}, then the result always has a time of midnight.
 * <p>
 * To convert to a specific time in a given time-zone call {@link #atTime(LocalTime)}
 * followed by {@link LocalDateTime#atZone(ZoneId)}.
 *
 * @param zone  the zone ID to use, not null
 * @return the zoned date-time formed from this date and the earliest valid time for the zone, not null
 */
public ZonedDateTime atStartOfDay(ZoneId zone) {
    Objects.requireNonNull(zone, "zone");
    // need to handle case where there is a gap from 11:30 to 00:30
    // standard ZDT factory would result in 01:00 rather than 00:30
    LocalDateTime ldt = atTime(LocalTime.MIDNIGHT);
    if (zone instanceof ZoneOffset == false) {
        ZoneRules rules = zone.getRules();
        ZoneOffsetTransition trans = rules.getTransition(ldt);
        if (trans != null && trans.isGap()) {
            ldt = trans.getDateTimeAfter();
        }
    }
    return ZonedDateTime.of(ldt, zone);
}
 
Example 3
Source File: LocalDate.java    From jdk8u-dev-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a zoned date-time from this date at the earliest valid time according
 * to the rules in the time-zone.
 * <p>
 * Time-zone rules, such as daylight savings, mean that not every local date-time
 * is valid for the specified zone, thus the local date-time may not be midnight.
 * <p>
 * In most cases, there is only one valid offset for a local date-time.
 * In the case of an overlap, there are two valid offsets, and the earlier one is used,
 * corresponding to the first occurrence of midnight on the date.
 * In the case of a gap, the zoned date-time will represent the instant just after the gap.
 * <p>
 * If the zone ID is a {@link ZoneOffset}, then the result always has a time of midnight.
 * <p>
 * To convert to a specific time in a given time-zone call {@link #atTime(LocalTime)}
 * followed by {@link LocalDateTime#atZone(ZoneId)}.
 *
 * @param zone  the zone ID to use, not null
 * @return the zoned date-time formed from this date and the earliest valid time for the zone, not null
 */
public ZonedDateTime atStartOfDay(ZoneId zone) {
    Objects.requireNonNull(zone, "zone");
    // need to handle case where there is a gap from 11:30 to 00:30
    // standard ZDT factory would result in 01:00 rather than 00:30
    LocalDateTime ldt = atTime(LocalTime.MIDNIGHT);
    if (zone instanceof ZoneOffset == false) {
        ZoneRules rules = zone.getRules();
        ZoneOffsetTransition trans = rules.getTransition(ldt);
        if (trans != null && trans.isGap()) {
            ldt = trans.getDateTimeAfter();
        }
    }
    return ZonedDateTime.of(ldt, zone);
}
 
Example 4
Source File: LocalDate.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a zoned date-time from this date at the earliest valid time according
 * to the rules in the time-zone.
 * <p>
 * Time-zone rules, such as daylight savings, mean that not every local date-time
 * is valid for the specified zone, thus the local date-time may not be midnight.
 * <p>
 * In most cases, there is only one valid offset for a local date-time.
 * In the case of an overlap, there are two valid offsets, and the earlier one is used,
 * corresponding to the first occurrence of midnight on the date.
 * In the case of a gap, the zoned date-time will represent the instant just after the gap.
 * <p>
 * If the zone ID is a {@link ZoneOffset}, then the result always has a time of midnight.
 * <p>
 * To convert to a specific time in a given time-zone call {@link #atTime(LocalTime)}
 * followed by {@link LocalDateTime#atZone(ZoneId)}.
 *
 * @param zone  the zone ID to use, not null
 * @return the zoned date-time formed from this date and the earliest valid time for the zone, not null
 */
public ZonedDateTime atStartOfDay(ZoneId zone) {
    Objects.requireNonNull(zone, "zone");
    // need to handle case where there is a gap from 11:30 to 00:30
    // standard ZDT factory would result in 01:00 rather than 00:30
    LocalDateTime ldt = atTime(LocalTime.MIDNIGHT);
    if (zone instanceof ZoneOffset == false) {
        ZoneRules rules = zone.getRules();
        ZoneOffsetTransition trans = rules.getTransition(ldt);
        if (trans != null && trans.isGap()) {
            ldt = trans.getDateTimeAfter();
        }
    }
    return ZonedDateTime.of(ldt, zone);
}
 
Example 5
Source File: LocalDate.java    From jdk8u_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a zoned date-time from this date at the earliest valid time according
 * to the rules in the time-zone.
 * <p>
 * Time-zone rules, such as daylight savings, mean that not every local date-time
 * is valid for the specified zone, thus the local date-time may not be midnight.
 * <p>
 * In most cases, there is only one valid offset for a local date-time.
 * In the case of an overlap, there are two valid offsets, and the earlier one is used,
 * corresponding to the first occurrence of midnight on the date.
 * In the case of a gap, the zoned date-time will represent the instant just after the gap.
 * <p>
 * If the zone ID is a {@link ZoneOffset}, then the result always has a time of midnight.
 * <p>
 * To convert to a specific time in a given time-zone call {@link #atTime(LocalTime)}
 * followed by {@link LocalDateTime#atZone(ZoneId)}.
 *
 * @param zone  the zone ID to use, not null
 * @return the zoned date-time formed from this date and the earliest valid time for the zone, not null
 */
public ZonedDateTime atStartOfDay(ZoneId zone) {
    Objects.requireNonNull(zone, "zone");
    // need to handle case where there is a gap from 11:30 to 00:30
    // standard ZDT factory would result in 01:00 rather than 00:30
    LocalDateTime ldt = atTime(LocalTime.MIDNIGHT);
    if (zone instanceof ZoneOffset == false) {
        ZoneRules rules = zone.getRules();
        ZoneOffsetTransition trans = rules.getTransition(ldt);
        if (trans != null && trans.isGap()) {
            ldt = trans.getDateTimeAfter();
        }
    }
    return ZonedDateTime.of(ldt, zone);
}
 
Example 6
Source File: LocalDate.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a zoned date-time from this date at the earliest valid time according
 * to the rules in the time-zone.
 * <p>
 * Time-zone rules, such as daylight savings, mean that not every local date-time
 * is valid for the specified zone, thus the local date-time may not be midnight.
 * <p>
 * In most cases, there is only one valid offset for a local date-time.
 * In the case of an overlap, there are two valid offsets, and the earlier one is used,
 * corresponding to the first occurrence of midnight on the date.
 * In the case of a gap, the zoned date-time will represent the instant just after the gap.
 * <p>
 * If the zone ID is a {@link ZoneOffset}, then the result always has a time of midnight.
 * <p>
 * To convert to a specific time in a given time-zone call {@link #atTime(LocalTime)}
 * followed by {@link LocalDateTime#atZone(ZoneId)}.
 *
 * @param zone  the zone ID to use, not null
 * @return the zoned date-time formed from this date and the earliest valid time for the zone, not null
 */
public ZonedDateTime atStartOfDay(ZoneId zone) {
    Objects.requireNonNull(zone, "zone");
    // need to handle case where there is a gap from 11:30 to 00:30
    // standard ZDT factory would result in 01:00 rather than 00:30
    LocalDateTime ldt = atTime(LocalTime.MIDNIGHT);
    if (zone instanceof ZoneOffset == false) {
        ZoneRules rules = zone.getRules();
        ZoneOffsetTransition trans = rules.getTransition(ldt);
        if (trans != null && trans.isGap()) {
            ldt = trans.getDateTimeAfter();
        }
    }
    return ZonedDateTime.of(ldt, zone);
}
 
Example 7
Source File: LocalDate.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a zoned date-time from this date at the earliest valid time according
 * to the rules in the time-zone.
 * <p>
 * Time-zone rules, such as daylight savings, mean that not every local date-time
 * is valid for the specified zone, thus the local date-time may not be midnight.
 * <p>
 * In most cases, there is only one valid offset for a local date-time.
 * In the case of an overlap, there are two valid offsets, and the earlier one is used,
 * corresponding to the first occurrence of midnight on the date.
 * In the case of a gap, the zoned date-time will represent the instant just after the gap.
 * <p>
 * If the zone ID is a {@link ZoneOffset}, then the result always has a time of midnight.
 * <p>
 * To convert to a specific time in a given time-zone call {@link #atTime(LocalTime)}
 * followed by {@link LocalDateTime#atZone(ZoneId)}.
 *
 * @param zone  the zone ID to use, not null
 * @return the zoned date-time formed from this date and the earliest valid time for the zone, not null
 */
public ZonedDateTime atStartOfDay(ZoneId zone) {
    Objects.requireNonNull(zone, "zone");
    // need to handle case where there is a gap from 11:30 to 00:30
    // standard ZDT factory would result in 01:00 rather than 00:30
    LocalDateTime ldt = atTime(LocalTime.MIDNIGHT);
    if (zone instanceof ZoneOffset == false) {
        ZoneRules rules = zone.getRules();
        ZoneOffsetTransition trans = rules.getTransition(ldt);
        if (trans != null && trans.isGap()) {
            ldt = trans.getDateTimeAfter();
        }
    }
    return ZonedDateTime.of(ldt, zone);
}
 
Example 8
Source File: LocalDate.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a zoned date-time from this date at the earliest valid time according
 * to the rules in the time-zone.
 * <p>
 * Time-zone rules, such as daylight savings, mean that not every local date-time
 * is valid for the specified zone, thus the local date-time may not be midnight.
 * <p>
 * In most cases, there is only one valid offset for a local date-time.
 * In the case of an overlap, there are two valid offsets, and the earlier one is used,
 * corresponding to the first occurrence of midnight on the date.
 * In the case of a gap, the zoned date-time will represent the instant just after the gap.
 * <p>
 * If the zone ID is a {@link ZoneOffset}, then the result always has a time of midnight.
 * <p>
 * To convert to a specific time in a given time-zone call {@link #atTime(LocalTime)}
 * followed by {@link LocalDateTime#atZone(ZoneId)}.
 *
 * @param zone  the zone ID to use, not null
 * @return the zoned date-time formed from this date and the earliest valid time for the zone, not null
 */
public ZonedDateTime atStartOfDay(ZoneId zone) {
    Objects.requireNonNull(zone, "zone");
    // need to handle case where there is a gap from 11:30 to 00:30
    // standard ZDT factory would result in 01:00 rather than 00:30
    LocalDateTime ldt = atTime(LocalTime.MIDNIGHT);
    if (zone instanceof ZoneOffset == false) {
        ZoneRules rules = zone.getRules();
        ZoneOffsetTransition trans = rules.getTransition(ldt);
        if (trans != null && trans.isGap()) {
            ldt = trans.getDateTimeAfter();
        }
    }
    return ZonedDateTime.of(ldt, zone);
}
 
Example 9
Source File: LocalDate.java    From Java8CN with Apache License 2.0 3 votes vote down vote up
/**
 * Returns a zoned date-time from this date at the earliest valid time according
 * to the rules in the time-zone.
 * <p>
 * Time-zone rules, such as daylight savings, mean that not every local date-time
 * is valid for the specified zone, thus the local date-time may not be midnight.
 * <p>
 * In most cases, there is only one valid offset for a local date-time.
 * In the case of an overlap, there are two valid offsets, and the earlier one is used,
 * corresponding to the first occurrence of midnight on the date.
 * In the case of a gap, the zoned date-time will represent the instant just after the gap.
 * <p>
 * If the zone ID is a {@link ZoneOffset}, then the result always has a time of midnight.
 * <p>
 * To convert to a specific time in a given time-zone call {@link #atTime(LocalTime)}
 * followed by {@link LocalDateTime#atZone(ZoneId)}.
 *
 * @param zone  the zone ID to use, not null
 * @return the zoned date-time formed from this date and the earliest valid time for the zone, not null
 */
public ZonedDateTime atStartOfDay(ZoneId zone) {
    Objects.requireNonNull(zone, "zone");
    // need to handle case where there is a gap from 11:30 to 00:30
    // standard ZDT factory would result in 01:00 rather than 00:30
    LocalDateTime ldt = atTime(LocalTime.MIDNIGHT);
    if (zone instanceof ZoneOffset == false) {
        ZoneRules rules = zone.getRules();
        ZoneOffsetTransition trans = rules.getTransition(ldt);
        if (trans != null && trans.isGap()) {
            ldt = trans.getDateTimeAfter();
        }
    }
    return ZonedDateTime.of(ldt, zone);
}
 
Example 10
Source File: LocalDate.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a zoned date-time from this date at the earliest valid time according
 * to the rules in the time-zone.
 * <p>
 * Time-zone rules, such as daylight savings, mean that not every local date-time
 * is valid for the specified zone, thus the local date-time may not be midnight.
 * <p>
 * In most cases, there is only one valid offset for a local date-time.
 * In the case of an overlap, there are two valid offsets, and the earlier one is used,
 * corresponding to the first occurrence of midnight on the date.
 * In the case of a gap, the zoned date-time will represent the instant just after the gap.
 * <p>
 * If the zone ID is a {@link ZoneOffset}, then the result always has a time of midnight.
 * <p>
 * To convert to a specific time in a given time-zone call {@link #atTime(LocalTime)}
 * followed by {@link LocalDateTime#atZone(ZoneId)}.
 *
 * @param zone  the zone ID to use, not null
 * @return the zoned date-time formed from this date and the earliest valid time for the zone, not null
 */
public ZonedDateTime atStartOfDay(ZoneId zone) {
    Objects.requireNonNull(zone, "zone");
    // need to handle case where there is a gap from 11:30 to 00:30
    // standard ZDT factory would result in 01:00 rather than 00:30
    LocalDateTime ldt = atTime(LocalTime.MIDNIGHT);
    if (zone instanceof ZoneOffset == false) {
        ZoneRules rules = zone.getRules();
        ZoneOffsetTransition trans = rules.getTransition(ldt);
        if (trans != null && trans.isGap()) {
            ldt = trans.getDateTimeAfter();
        }
    }
    return ZonedDateTime.of(ldt, zone);
}
 
Example 11
Source File: LocalDate.java    From jdk1.8-source-analysis with Apache License 2.0 3 votes vote down vote up
/**
 * Returns a zoned date-time from this date at the earliest valid time according
 * to the rules in the time-zone.
 * <p>
 * Time-zone rules, such as daylight savings, mean that not every local date-time
 * is valid for the specified zone, thus the local date-time may not be midnight.
 * <p>
 * In most cases, there is only one valid offset for a local date-time.
 * In the case of an overlap, there are two valid offsets, and the earlier one is used,
 * corresponding to the first occurrence of midnight on the date.
 * In the case of a gap, the zoned date-time will represent the instant just after the gap.
 * <p>
 * If the zone ID is a {@link ZoneOffset}, then the result always has a time of midnight.
 * <p>
 * To convert to a specific time in a given time-zone call {@link #atTime(LocalTime)}
 * followed by {@link LocalDateTime#atZone(ZoneId)}.
 *
 * @param zone  the zone ID to use, not null
 * @return the zoned date-time formed from this date and the earliest valid time for the zone, not null
 */
public ZonedDateTime atStartOfDay(ZoneId zone) {
    Objects.requireNonNull(zone, "zone");
    // need to handle case where there is a gap from 11:30 to 00:30
    // standard ZDT factory would result in 01:00 rather than 00:30
    LocalDateTime ldt = atTime(LocalTime.MIDNIGHT);
    if (zone instanceof ZoneOffset == false) {
        ZoneRules rules = zone.getRules();
        ZoneOffsetTransition trans = rules.getTransition(ldt);
        if (trans != null && trans.isGap()) {
            ldt = trans.getDateTimeAfter();
        }
    }
    return ZonedDateTime.of(ldt, zone);
}
 
Example 12
Source File: LocalDate.java    From Bytecoder with Apache License 2.0 3 votes vote down vote up
/**
 * Returns a zoned date-time from this date at the earliest valid time according
 * to the rules in the time-zone.
 * <p>
 * Time-zone rules, such as daylight savings, mean that not every local date-time
 * is valid for the specified zone, thus the local date-time may not be midnight.
 * <p>
 * In most cases, there is only one valid offset for a local date-time.
 * In the case of an overlap, there are two valid offsets, and the earlier one is used,
 * corresponding to the first occurrence of midnight on the date.
 * In the case of a gap, the zoned date-time will represent the instant just after the gap.
 * <p>
 * If the zone ID is a {@link ZoneOffset}, then the result always has a time of midnight.
 * <p>
 * To convert to a specific time in a given time-zone call {@link #atTime(LocalTime)}
 * followed by {@link LocalDateTime#atZone(ZoneId)}.
 *
 * @param zone  the zone ID to use, not null
 * @return the zoned date-time formed from this date and the earliest valid time for the zone, not null
 */
public ZonedDateTime atStartOfDay(ZoneId zone) {
    Objects.requireNonNull(zone, "zone");
    // need to handle case where there is a gap from 11:30 to 00:30
    // standard ZDT factory would result in 01:00 rather than 00:30
    LocalDateTime ldt = atTime(LocalTime.MIDNIGHT);
    if (zone instanceof ZoneOffset == false) {
        ZoneRules rules = zone.getRules();
        ZoneOffsetTransition trans = rules.getTransition(ldt);
        if (trans != null && trans.isGap()) {
            ldt = trans.getDateTimeAfter();
        }
    }
    return ZonedDateTime.of(ldt, zone);
}
 
Example 13
Source File: LocalDate.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a zoned date-time from this date at the earliest valid time according
 * to the rules in the time-zone.
 * <p>
 * Time-zone rules, such as daylight savings, mean that not every local date-time
 * is valid for the specified zone, thus the local date-time may not be midnight.
 * <p>
 * In most cases, there is only one valid offset for a local date-time.
 * In the case of an overlap, there are two valid offsets, and the earlier one is used,
 * corresponding to the first occurrence of midnight on the date.
 * In the case of a gap, the zoned date-time will represent the instant just after the gap.
 * <p>
 * If the zone ID is a {@link ZoneOffset}, then the result always has a time of midnight.
 * <p>
 * To convert to a specific time in a given time-zone call {@link #atTime(LocalTime)}
 * followed by {@link LocalDateTime#atZone(ZoneId)}.
 *
 * @param zone  the zone ID to use, not null
 * @return the zoned date-time formed from this date and the earliest valid time for the zone, not null
 */
public ZonedDateTime atStartOfDay(ZoneId zone) {
    Objects.requireNonNull(zone, "zone");
    // need to handle case where there is a gap from 11:30 to 00:30
    // standard ZDT factory would result in 01:00 rather than 00:30
    LocalDateTime ldt = atTime(LocalTime.MIDNIGHT);
    if (zone instanceof ZoneOffset == false) {
        ZoneRules rules = zone.getRules();
        ZoneOffsetTransition trans = rules.getTransition(ldt);
        if (trans != null && trans.isGap()) {
            ldt = trans.getDateTimeAfter();
        }
    }
    return ZonedDateTime.of(ldt, zone);
}
 
Example 14
Source File: LocalDate.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a zoned date-time from this date at the earliest valid time according
 * to the rules in the time-zone.
 * <p>
 * Time-zone rules, such as daylight savings, mean that not every local date-time
 * is valid for the specified zone, thus the local date-time may not be midnight.
 * <p>
 * In most cases, there is only one valid offset for a local date-time.
 * In the case of an overlap, there are two valid offsets, and the earlier one is used,
 * corresponding to the first occurrence of midnight on the date.
 * In the case of a gap, the zoned date-time will represent the instant just after the gap.
 * <p>
 * If the zone ID is a {@link ZoneOffset}, then the result always has a time of midnight.
 * <p>
 * To convert to a specific time in a given time-zone call {@link #atTime(LocalTime)}
 * followed by {@link LocalDateTime#atZone(ZoneId)}.
 *
 * @param zone  the zone ID to use, not null
 * @return the zoned date-time formed from this date and the earliest valid time for the zone, not null
 */
public ZonedDateTime atStartOfDay(ZoneId zone) {
    Objects.requireNonNull(zone, "zone");
    // need to handle case where there is a gap from 11:30 to 00:30
    // standard ZDT factory would result in 01:00 rather than 00:30
    LocalDateTime ldt = atTime(LocalTime.MIDNIGHT);
    if (zone instanceof ZoneOffset == false) {
        ZoneRules rules = zone.getRules();
        ZoneOffsetTransition trans = rules.getTransition(ldt);
        if (trans != null && trans.isGap()) {
            ldt = trans.getDateTimeAfter();
        }
    }
    return ZonedDateTime.of(ldt, zone);
}
 
Example 15
Source File: LocalDate.java    From desugar_jdk_libs with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a zoned date-time from this date at the earliest valid time according
 * to the rules in the time-zone.
 * <p>
 * Time-zone rules, such as daylight savings, mean that not every local date-time
 * is valid for the specified zone, thus the local date-time may not be midnight.
 * <p>
 * In most cases, there is only one valid offset for a local date-time.
 * In the case of an overlap, there are two valid offsets, and the earlier one is used,
 * corresponding to the first occurrence of midnight on the date.
 * In the case of a gap, the zoned date-time will represent the instant just after the gap.
 * <p>
 * If the zone ID is a {@link ZoneOffset}, then the result always has a time of midnight.
 * <p>
 * To convert to a specific time in a given time-zone call {@link #atTime(LocalTime)}
 * followed by {@link LocalDateTime#atZone(ZoneId)}.
 *
 * @param zone  the zone ID to use, not null
 * @return the zoned date-time formed from this date and the earliest valid time for the zone, not null
 */
public ZonedDateTime atStartOfDay(ZoneId zone) {
    Objects.requireNonNull(zone, "zone");
    // need to handle case where there is a gap from 11:30 to 00:30
    // standard ZDT factory would result in 01:00 rather than 00:30
    LocalDateTime ldt = atTime(LocalTime.MIDNIGHT);
    if (zone instanceof ZoneOffset == false) {
        ZoneRules rules = zone.getRules();
        ZoneOffsetTransition trans = rules.getTransition(ldt);
        if (trans != null && trans.isGap()) {
            ldt = trans.getDateTimeAfter();
        }
    }
    return ZonedDateTime.of(ldt, zone);
}
 
Example 16
Source File: LocalDate.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * Returns a zoned date-time from this date at the earliest valid time according
 * to the rules in the time-zone.
 * <p>
 * Time-zone rules, such as daylight savings, mean that not every local date-time
 * is valid for the specified zone, thus the local date-time may not be midnight.
 * <p>
 * In most cases, there is only one valid offset for a local date-time.
 * In the case of an overlap, there are two valid offsets, and the earlier one is used,
 * corresponding to the first occurrence of midnight on the date.
 * In the case of a gap, the zoned date-time will represent the instant just after the gap.
 * <p>
 * If the zone ID is a {@link ZoneOffset}, then the result always has a time of midnight.
 * <p>
 * To convert to a specific time in a given time-zone call {@link #atTime(LocalTime)}
 * followed by {@link LocalDateTime#atZone(ZoneId)}.
 *
 * @param zone  the zone ID to use, not null
 * @return the zoned date-time formed from this date and the earliest valid time for the zone, not null
 */
public ZonedDateTime atStartOfDay(ZoneId zone) {
    Objects.requireNonNull(zone, "zone");
    // need to handle case where there is a gap from 11:30 to 00:30
    // standard ZDT factory would result in 01:00 rather than 00:30
    LocalDateTime ldt = atTime(LocalTime.MIDNIGHT);
    if (zone instanceof ZoneOffset == false) {
        ZoneRules rules = zone.getRules();
        ZoneOffsetTransition trans = rules.getTransition(ldt);
        if (trans != null && trans.isGap()) {
            ldt = trans.getDateTimeAfter();
        }
    }
    return ZonedDateTime.of(ldt, zone);
}
 
Example 17
Source File: LocalDate.java    From jdk8u60 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a zoned date-time from this date at the earliest valid time according
 * to the rules in the time-zone.
 * <p>
 * Time-zone rules, such as daylight savings, mean that not every local date-time
 * is valid for the specified zone, thus the local date-time may not be midnight.
 * <p>
 * In most cases, there is only one valid offset for a local date-time.
 * In the case of an overlap, there are two valid offsets, and the earlier one is used,
 * corresponding to the first occurrence of midnight on the date.
 * In the case of a gap, the zoned date-time will represent the instant just after the gap.
 * <p>
 * If the zone ID is a {@link ZoneOffset}, then the result always has a time of midnight.
 * <p>
 * To convert to a specific time in a given time-zone call {@link #atTime(LocalTime)}
 * followed by {@link LocalDateTime#atZone(ZoneId)}.
 *
 * @param zone  the zone ID to use, not null
 * @return the zoned date-time formed from this date and the earliest valid time for the zone, not null
 */
public ZonedDateTime atStartOfDay(ZoneId zone) {
    Objects.requireNonNull(zone, "zone");
    // need to handle case where there is a gap from 11:30 to 00:30
    // standard ZDT factory would result in 01:00 rather than 00:30
    LocalDateTime ldt = atTime(LocalTime.MIDNIGHT);
    if (zone instanceof ZoneOffset == false) {
        ZoneRules rules = zone.getRules();
        ZoneOffsetTransition trans = rules.getTransition(ldt);
        if (trans != null && trans.isGap()) {
            ldt = trans.getDateTimeAfter();
        }
    }
    return ZonedDateTime.of(ldt, zone);
}
 
Example 18
Source File: LocalDate.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a zoned date-time from this date at the earliest valid time according
 * to the rules in the time-zone.
 * <p>
 * Time-zone rules, such as daylight savings, mean that not every local date-time
 * is valid for the specified zone, thus the local date-time may not be midnight.
 * <p>
 * In most cases, there is only one valid offset for a local date-time.
 * In the case of an overlap, there are two valid offsets, and the earlier one is used,
 * corresponding to the first occurrence of midnight on the date.
 * In the case of a gap, the zoned date-time will represent the instant just after the gap.
 * <p>
 * If the zone ID is a {@link ZoneOffset}, then the result always has a time of midnight.
 * <p>
 * To convert to a specific time in a given time-zone call {@link #atTime(LocalTime)}
 * followed by {@link LocalDateTime#atZone(ZoneId)}.
 *
 * @param zone  the zone ID to use, not null
 * @return the zoned date-time formed from this date and the earliest valid time for the zone, not null
 */
public ZonedDateTime atStartOfDay(ZoneId zone) {
    Objects.requireNonNull(zone, "zone");
    // need to handle case where there is a gap from 11:30 to 00:30
    // standard ZDT factory would result in 01:00 rather than 00:30
    LocalDateTime ldt = atTime(LocalTime.MIDNIGHT);
    if (zone instanceof ZoneOffset == false) {
        ZoneRules rules = zone.getRules();
        ZoneOffsetTransition trans = rules.getTransition(ldt);
        if (trans != null && trans.isGap()) {
            ldt = trans.getDateTimeAfter();
        }
    }
    return ZonedDateTime.of(ldt, zone);
}
 
Example 19
Source File: LocalDate.java    From dragonwell8_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a zoned date-time from this date at the earliest valid time according
 * to the rules in the time-zone.
 * <p>
 * Time-zone rules, such as daylight savings, mean that not every local date-time
 * is valid for the specified zone, thus the local date-time may not be midnight.
 * <p>
 * In most cases, there is only one valid offset for a local date-time.
 * In the case of an overlap, there are two valid offsets, and the earlier one is used,
 * corresponding to the first occurrence of midnight on the date.
 * In the case of a gap, the zoned date-time will represent the instant just after the gap.
 * <p>
 * If the zone ID is a {@link ZoneOffset}, then the result always has a time of midnight.
 * <p>
 * To convert to a specific time in a given time-zone call {@link #atTime(LocalTime)}
 * followed by {@link LocalDateTime#atZone(ZoneId)}.
 *
 * @param zone  the zone ID to use, not null
 * @return the zoned date-time formed from this date and the earliest valid time for the zone, not null
 */
public ZonedDateTime atStartOfDay(ZoneId zone) {
    Objects.requireNonNull(zone, "zone");
    // need to handle case where there is a gap from 11:30 to 00:30
    // standard ZDT factory would result in 01:00 rather than 00:30
    LocalDateTime ldt = atTime(LocalTime.MIDNIGHT);
    if (zone instanceof ZoneOffset == false) {
        ZoneRules rules = zone.getRules();
        ZoneOffsetTransition trans = rules.getTransition(ldt);
        if (trans != null && trans.isGap()) {
            ldt = trans.getDateTimeAfter();
        }
    }
    return ZonedDateTime.of(ldt, zone);
}