Path: blob/master/src/java.base/share/classes/java/time/format/ResolverStyle.java
41159 views
/*1* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425/*26* This file is available under and governed by the GNU General Public27* License version 2 only, as published by the Free Software Foundation.28* However, the following notice accompanied the original version of this29* file:30*31* Copyright (c) 2008-2013, Stephen Colebourne & Michael Nascimento Santos32*33* All rights reserved.34*35* Redistribution and use in source and binary forms, with or without36* modification, are permitted provided that the following conditions are met:37*38* * Redistributions of source code must retain the above copyright notice,39* this list of conditions and the following disclaimer.40*41* * Redistributions in binary form must reproduce the above copyright notice,42* this list of conditions and the following disclaimer in the documentation43* and/or other materials provided with the distribution.44*45* * Neither the name of JSR-310 nor the names of its contributors46* may be used to endorse or promote products derived from this software47* without specific prior written permission.48*49* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS50* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT51* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR52* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR53* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,54* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,55* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR56* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF57* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING58* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS59* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.60*/61package java.time.format;6263/**64* Enumeration of different ways to resolve dates and times.65* <p>66* Parsing a text string occurs in two phases.67* Phase 1 is a basic text parse according to the fields added to the builder.68* Phase 2 resolves the parsed field-value pairs into date and/or time objects.69* This style is used to control how phase 2, resolving, happens.70*71* @implSpec72* This is an immutable and thread-safe enum.73*74* @since 1.875*/76public enum ResolverStyle {7778/**79* Style to resolve dates and times strictly.80* <p>81* Using strict resolution will ensure that all parsed values are within82* the outer range of valid values for the field. Individual fields may83* be further processed for strictness.84* <p>85* For example, resolving year-month and day-of-month in the ISO calendar86* system using strict mode will ensure that the day-of-month is valid87* for the year-month, rejecting invalid values.88*/89STRICT,90/**91* Style to resolve dates and times in a smart, or intelligent, manner.92* <p>93* Using smart resolution will perform the sensible default for each94* field, which may be the same as strict, the same as lenient, or a third95* behavior. Individual fields will interpret this differently.96* <p>97* For example, resolving year-month and day-of-month in the ISO calendar98* system using smart mode will ensure that the day-of-month is from99* 1 to 31, converting any value beyond the last valid day-of-month to be100* the last valid day-of-month.101*/102SMART,103/**104* Style to resolve dates and times leniently.105* <p>106* Using lenient resolution will resolve the values in an appropriate107* lenient manner. Individual fields will interpret this differently.108* <p>109* For example, lenient mode allows the month in the ISO calendar system110* to be outside the range 1 to 12.111* For example, month 15 is treated as being 3 months after month 12.112*/113LENIENT;114115}116117118