1 /*
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
78 * from a persistent data store, such as a database, and to send dates and times across a network.
79 * The "chrono" classes are then used at the user interface level to deal with localized input/output.
80 * See {@link java.time.chrono.ChronoLocalDate ChronoLocalDate}
81 * for a full discussion of the issues.
82 * </p>
83 * <p>
84 * Using non-ISO calendar systems in an application introduces significant extra complexity.
85 * Ensure that the warnings and recommendations in {@code ChronoLocalDate} have been read before
86 * working with the "chrono" interfaces.
87 * </p>
88 * <p>
89 * The supported calendar systems includes:
90 * </p>
91 * <ul>
92 * <li>{@link java.time.chrono.HijrahChronology Hijrah calendar}</li>
93 * <li>{@link java.time.chrono.JapaneseChronology Japanese calendar}</li>
94 * <li>{@link java.time.chrono.MinguoChronology Minguo calendar}</li>
95 * <li>{@link java.time.chrono.ThaiBuddhistChronology Thai Buddhist calendar}</li>
96 * </ul>
97 *
98 * <h3>Example</h3>
99 * <p>
100 * This example lists todays date for all of the available calendars.
101 * </p>
102 * <pre>
103 * // Enumerate the list of available calendars and print todays date for each.
104 * Set<Chronology> chronos = Chronology.getAvailableChronologies();
105 * for (Chronology chrono : chronos) {
106 * ChronoLocalDate date = chrono.dateNow();
107 * System.out.printf(" %20s: %s%n", chrono.getId(), date.toString());
108 * }
109 * </pre>
110 *
111 * <p>
112 * This example creates and uses a date in a named non-ISO calendar system.
113 * </p>
114 * <pre>
115 * // Print the Thai Buddhist date
116 * ChronoLocalDate now1 = Chronology.of("ThaiBuddhist").dateNow();
117 * int day = now1.get(ChronoField.DAY_OF_MONTH);
118 * int dow = now1.get(ChronoField.DAY_OF_WEEK);
138 * // Print the Thai Buddhist date
139 * ThaiBuddhistDate now1 = ThaiBuddhistDate.now();
140 * int day = now1.get(ChronoField.DAY_OF_MONTH);
141 * int dow = now1.get(ChronoField.DAY_OF_WEEK);
142 * int month = now1.get(ChronoField.MONTH_OF_YEAR);
143 * int year = now1.get(ChronoField.YEAR);
144 * System.out.printf(" Today is %s %s %d-%s-%d%n", now1.getChronology().getId(),
145 * dow, day, month, year);
146 *
147 * // Print today's date and the last day of the year for the Thai Buddhist Calendar.
148 * ThaiBuddhistDate first = now1
149 * .with(ChronoField.DAY_OF_MONTH, 1)
150 * .with(ChronoField.MONTH_OF_YEAR, 1);
151 * ThaiBuddhistDate last = first
152 * .plus(1, ChronoUnit.YEARS)
153 * .minus(1, ChronoUnit.DAYS);
154 * System.out.printf(" %s: 1st of year: %s; end of year: %s%n", last.getChronology().getId(),
155 * first, last);
156 * </pre>
157 *
158 * <h3>Package specification</h3>
159 * <p>
160 * Unless otherwise noted, passing a null argument to a constructor or method in any class or interface
161 * in this package will cause a {@link java.lang.NullPointerException NullPointerException} to be thrown.
162 * The Javadoc "@param" definition is used to summarise the null-behavior.
163 * The "@throws {@link java.lang.NullPointerException}" is not explicitly documented in each method.
164 * </p>
165 * <p>
166 * All calculations should check for numeric overflow and throw either an {@link java.lang.ArithmeticException}
167 * or a {@link java.time.DateTimeException}.
168 * </p>
169 * @since 1.8
170 */
171 package java.time.chrono;
|
1 /*
2 * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
78 * from a persistent data store, such as a database, and to send dates and times across a network.
79 * The "chrono" classes are then used at the user interface level to deal with localized input/output.
80 * See {@link java.time.chrono.ChronoLocalDate ChronoLocalDate}
81 * for a full discussion of the issues.
82 * </p>
83 * <p>
84 * Using non-ISO calendar systems in an application introduces significant extra complexity.
85 * Ensure that the warnings and recommendations in {@code ChronoLocalDate} have been read before
86 * working with the "chrono" interfaces.
87 * </p>
88 * <p>
89 * The supported calendar systems includes:
90 * </p>
91 * <ul>
92 * <li>{@link java.time.chrono.HijrahChronology Hijrah calendar}</li>
93 * <li>{@link java.time.chrono.JapaneseChronology Japanese calendar}</li>
94 * <li>{@link java.time.chrono.MinguoChronology Minguo calendar}</li>
95 * <li>{@link java.time.chrono.ThaiBuddhistChronology Thai Buddhist calendar}</li>
96 * </ul>
97 *
98 * <h2>Example</h2>
99 * <p>
100 * This example lists todays date for all of the available calendars.
101 * </p>
102 * <pre>
103 * // Enumerate the list of available calendars and print todays date for each.
104 * Set<Chronology> chronos = Chronology.getAvailableChronologies();
105 * for (Chronology chrono : chronos) {
106 * ChronoLocalDate date = chrono.dateNow();
107 * System.out.printf(" %20s: %s%n", chrono.getId(), date.toString());
108 * }
109 * </pre>
110 *
111 * <p>
112 * This example creates and uses a date in a named non-ISO calendar system.
113 * </p>
114 * <pre>
115 * // Print the Thai Buddhist date
116 * ChronoLocalDate now1 = Chronology.of("ThaiBuddhist").dateNow();
117 * int day = now1.get(ChronoField.DAY_OF_MONTH);
118 * int dow = now1.get(ChronoField.DAY_OF_WEEK);
138 * // Print the Thai Buddhist date
139 * ThaiBuddhistDate now1 = ThaiBuddhistDate.now();
140 * int day = now1.get(ChronoField.DAY_OF_MONTH);
141 * int dow = now1.get(ChronoField.DAY_OF_WEEK);
142 * int month = now1.get(ChronoField.MONTH_OF_YEAR);
143 * int year = now1.get(ChronoField.YEAR);
144 * System.out.printf(" Today is %s %s %d-%s-%d%n", now1.getChronology().getId(),
145 * dow, day, month, year);
146 *
147 * // Print today's date and the last day of the year for the Thai Buddhist Calendar.
148 * ThaiBuddhistDate first = now1
149 * .with(ChronoField.DAY_OF_MONTH, 1)
150 * .with(ChronoField.MONTH_OF_YEAR, 1);
151 * ThaiBuddhistDate last = first
152 * .plus(1, ChronoUnit.YEARS)
153 * .minus(1, ChronoUnit.DAYS);
154 * System.out.printf(" %s: 1st of year: %s; end of year: %s%n", last.getChronology().getId(),
155 * first, last);
156 * </pre>
157 *
158 * <h2>Package specification</h2>
159 * <p>
160 * Unless otherwise noted, passing a null argument to a constructor or method in any class or interface
161 * in this package will cause a {@link java.lang.NullPointerException NullPointerException} to be thrown.
162 * The Javadoc "@param" definition is used to summarise the null-behavior.
163 * The "@throws {@link java.lang.NullPointerException}" is not explicitly documented in each method.
164 * </p>
165 * <p>
166 * All calculations should check for numeric overflow and throw either an {@link java.lang.ArithmeticException}
167 * or a {@link java.time.DateTimeException}.
168 * </p>
169 * @since 1.8
170 */
171 package java.time.chrono;
|