< prev index next >

src/java.base/share/classes/java/time/ZoneId.java

Print this page




  44  *    and/or other materials provided with the distribution.
  45  *
  46  *  * Neither the name of JSR-310 nor the names of its contributors
  47  *    may be used to endorse or promote products derived from this software
  48  *    without specific prior written permission.
  49  *
  50  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  51  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  52  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  53  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  54  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  55  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  56  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  57  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  58  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  59  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  60  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  61  */
  62 package java.time;
  63 


  64 import java.io.DataOutput;
  65 import java.io.IOException;
  66 import java.io.InvalidObjectException;
  67 import java.io.ObjectInputStream;
  68 import java.io.Serializable;
  69 import java.time.format.DateTimeFormatterBuilder;
  70 import java.time.format.TextStyle;
  71 import java.time.temporal.TemporalAccessor;
  72 import java.time.temporal.TemporalField;
  73 import java.time.temporal.TemporalQueries;
  74 import java.time.temporal.TemporalQuery;
  75 import java.time.temporal.UnsupportedTemporalTypeException;
  76 import java.time.zone.ZoneRules;
  77 import java.time.zone.ZoneRulesException;
  78 import java.time.zone.ZoneRulesProvider;
  79 import java.util.Collections;
  80 import java.util.HashMap;
  81 import java.util.Locale;
  82 import java.util.Map;
  83 import java.util.Objects;


 254         SHORT_IDS = Collections.unmodifiableMap(map);
 255     }
 256     /**
 257      * Serialization version.
 258      */
 259     private static final long serialVersionUID = 8352817235686L;
 260 
 261     //-----------------------------------------------------------------------
 262     /**
 263      * Gets the system default time-zone.
 264      * <p>
 265      * This queries {@link TimeZone#getDefault()} to find the default time-zone
 266      * and converts it to a {@code ZoneId}. If the system default time-zone is changed,
 267      * then the result of this method will also change.
 268      *
 269      * @return the zone ID, not null
 270      * @throws DateTimeException if the converted zone ID has an invalid format
 271      * @throws ZoneRulesException if the converted zone region ID cannot be found
 272      */
 273     public static ZoneId systemDefault() {
 274         return TimeZone.getDefault().toZoneId();
 275     }
 276 
 277     /**
 278      * Gets the set of available zone IDs.
 279      * <p>
 280      * This set includes the string form of all available region-based IDs.
 281      * Offset-based zone IDs are not included in the returned set.
 282      * The ID can be passed to {@link #of(String)} to create a {@code ZoneId}.
 283      * <p>
 284      * The set of zone IDs can increase over time, although in a typical application
 285      * the set of IDs is fixed. Each call to this method is thread-safe.
 286      *
 287      * @return a modifiable copy of the set of zone IDs, not null
 288      */
 289     public static Set<String> getAvailableZoneIds() {
 290         return ZoneRulesProvider.getAvailableZoneIds();
 291     }
 292 
 293     //-----------------------------------------------------------------------
 294     /**




  44  *    and/or other materials provided with the distribution.
  45  *
  46  *  * Neither the name of JSR-310 nor the names of its contributors
  47  *    may be used to endorse or promote products derived from this software
  48  *    without specific prior written permission.
  49  *
  50  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  51  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  52  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  53  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  54  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  55  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  56  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  57  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  58  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  59  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  60  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  61  */
  62 package java.time;
  63 
  64 import sun.misc.SharedSecrets;
  65 
  66 import java.io.DataOutput;
  67 import java.io.IOException;
  68 import java.io.InvalidObjectException;
  69 import java.io.ObjectInputStream;
  70 import java.io.Serializable;
  71 import java.time.format.DateTimeFormatterBuilder;
  72 import java.time.format.TextStyle;
  73 import java.time.temporal.TemporalAccessor;
  74 import java.time.temporal.TemporalField;
  75 import java.time.temporal.TemporalQueries;
  76 import java.time.temporal.TemporalQuery;
  77 import java.time.temporal.UnsupportedTemporalTypeException;
  78 import java.time.zone.ZoneRules;
  79 import java.time.zone.ZoneRulesException;
  80 import java.time.zone.ZoneRulesProvider;
  81 import java.util.Collections;
  82 import java.util.HashMap;
  83 import java.util.Locale;
  84 import java.util.Map;
  85 import java.util.Objects;


 256         SHORT_IDS = Collections.unmodifiableMap(map);
 257     }
 258     /**
 259      * Serialization version.
 260      */
 261     private static final long serialVersionUID = 8352817235686L;
 262 
 263     //-----------------------------------------------------------------------
 264     /**
 265      * Gets the system default time-zone.
 266      * <p>
 267      * This queries {@link TimeZone#getDefault()} to find the default time-zone
 268      * and converts it to a {@code ZoneId}. If the system default time-zone is changed,
 269      * then the result of this method will also change.
 270      *
 271      * @return the zone ID, not null
 272      * @throws DateTimeException if the converted zone ID has an invalid format
 273      * @throws ZoneRulesException if the converted zone region ID cannot be found
 274      */
 275     public static ZoneId systemDefault() {
 276         return SharedSecrets.getJavaUtilTimeZoneAccess().getDefaultRef().toZoneId();
 277     }
 278 
 279     /**
 280      * Gets the set of available zone IDs.
 281      * <p>
 282      * This set includes the string form of all available region-based IDs.
 283      * Offset-based zone IDs are not included in the returned set.
 284      * The ID can be passed to {@link #of(String)} to create a {@code ZoneId}.
 285      * <p>
 286      * The set of zone IDs can increase over time, although in a typical application
 287      * the set of IDs is fixed. Each call to this method is thread-safe.
 288      *
 289      * @return a modifiable copy of the set of zone IDs, not null
 290      */
 291     public static Set<String> getAvailableZoneIds() {
 292         return ZoneRulesProvider.getAvailableZoneIds();
 293     }
 294 
 295     //-----------------------------------------------------------------------
 296     /**


< prev index next >