1 /*
2 * Copyright (c) 2005, 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
26 package sun.util.calendar;
27
28 import java.security.AccessController;
29 import java.util.TimeZone;
30 import java.util.regex.Matcher;
31 import java.util.regex.Pattern;
32 import sun.security.action.GetPropertyAction;
33
34 /**
35 *
36 * @author Masayoshi Okutsu
37 * @since 1.6
38 */
39
40 public class LocalGregorianCalendar extends BaseCalendar {
41 private static final Era[] JAPANESE_ERAS = {
42 new Era("Meiji", "M", -3218832000000L, true),
43 new Era("Taisho", "T", -1812153600000L, true),
44 new Era("Showa", "S", -1357603200000L, true),
45 new Era("Heisei", "H", 600220800000L, true),
46 new Era("NewEra", "N", 1556668800000L, true),
47 };
48
49 private static boolean isValidEra(Era newEra, Era[] eras) {
50 Era last = eras[eras.length - 1];
51 if (last.getSince(null) >= newEra.getSince(null)) {
52 return false;
53 }
54 // The new era name should be unique. Its abbr may not.
55 String newName = newEra.getName();
56 for (Era era : eras) {
57 if (era.getName().equals(newName)) {
58 return false;
59 }
60 }
61 return true;
62 }
63
64 private String name;
65 private Era[] eras;
66
|
1 /*
2 * Copyright (c) 2005, 2019, 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
26 package sun.util.calendar;
27
28 import java.security.AccessController;
29 import java.util.TimeZone;
30 import java.util.regex.Matcher;
31 import java.util.regex.Pattern;
32 import sun.security.action.GetPropertyAction;
33
34 /**
35 *
36 * @author Masayoshi Okutsu
37 * @since 1.6
38 */
39
40 public class LocalGregorianCalendar extends BaseCalendar {
41 private static final Era[] JAPANESE_ERAS = {
42 new Era("Meiji", "M", -3218832000000L, true),
43 new Era("Taisho", "T", -1812153600000L, true),
44 new Era("Showa", "S", -1357603200000L, true),
45 new Era("Heisei", "H", 600220800000L, true),
46 new Era("Reiwa", "R", 1556668800000L, true),
47 };
48
49 private static boolean isValidEra(Era newEra, Era[] eras) {
50 Era last = eras[eras.length - 1];
51 if (last.getSince(null) >= newEra.getSince(null)) {
52 return false;
53 }
54 // The new era name should be unique. Its abbr may not.
55 String newName = newEra.getName();
56 for (Era era : eras) {
57 if (era.getName().equals(newName)) {
58 return false;
59 }
60 }
61 return true;
62 }
63
64 private String name;
65 private Era[] eras;
66
|