src/share/classes/java/util/GregorianCalendar.java

Print this page
rev 5615 : 6336885: RFE: Locale Data Deployment Enhancements
4609153: Provide locale data for Indic locales
5104387: Support for gl_ES locale (galician language)
6337471: desktop/system locale preferences support
7056139: (cal) SPI support for locale-dependent Calendar parameters
7058206: Provide CalendarData SPI for week params and display field value names
7073852: Support multiple scripts for digits and decimal symbols per locale
7079560: [Fmt-Da] Context dependent month names support in SimpleDateFormat
7171324: getAvailableLocales() of locale sensitive services should return the actual availability of locales
7151414: (cal) Support calendar type identification
7168528: LocaleServiceProvider needs to be aware of Locale extensions
7171372: (cal) locale's default Calendar should be created if unknown calendar is specified
Summary: JEP 127: Improve Locale Data Packaging and Adopt Unicode CLDR Data (part 1 w/o Jigsaw. by Naoto Sato and Masayoshi Okutsu)

*** 1,7 **** /* ! * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 38,47 **** --- 38,48 ---- package java.util; import java.io.IOException; import java.io.ObjectInputStream; + import sun.util.locale.provider.CalendarDataUtility; import sun.util.calendar.BaseCalendar; import sun.util.calendar.CalendarDate; import sun.util.calendar.CalendarSystem; import sun.util.calendar.CalendarUtils; import sun.util.calendar.Era;
*** 490,499 **** --- 491,501 ---- 14*ONE_HOUR, // ZONE_OFFSET 2*ONE_HOUR // DST_OFFSET (double summer time) }; // Proclaim serialization compatibility with JDK 1.1 + @SuppressWarnings("FieldNameHidesFieldInSuperclass") static final long serialVersionUID = -8125100834729963327L; // Reference to the sun.util.calendar.Gregorian instance (singleton). private static final Gregorian gcal = CalendarSystem.getGregorianCalendar();
*** 763,775 **** BaseCalendar.Date d = getGregorianCutoverDate(); // Set the cutover year (in the Gregorian year numbering) gregorianCutoverYear = d.getYear(); ! BaseCalendar jcal = getJulianCalendarSystem(); ! d = (BaseCalendar.Date) jcal.newCalendarDate(TimeZone.NO_TIMEZONE); ! jcal.getCalendarDateFromFixedDate(d, gregorianCutoverDate - 1); gregorianCutoverYearJulian = d.getNormalizedYear(); if (time < gregorianCutover) { // The field values are no longer valid under the new // cutover date. --- 765,777 ---- BaseCalendar.Date d = getGregorianCutoverDate(); // Set the cutover year (in the Gregorian year numbering) gregorianCutoverYear = d.getYear(); ! BaseCalendar julianCal = getJulianCalendarSystem(); ! d = (BaseCalendar.Date) julianCal.newCalendarDate(TimeZone.NO_TIMEZONE); ! julianCal.getCalendarDateFromFixedDate(d, gregorianCutoverDate - 1); gregorianCutoverYearJulian = d.getNormalizedYear(); if (time < gregorianCutover) { // The field values are no longer valid under the new // cutover date.
*** 820,829 **** --- 822,842 ---- } return gregorian ? (year%100 != 0) || (year%400 == 0) : true; } /** + * Returns {@code "gregory"} as the calendar type. + * + * @return {@code "gregory"} + * @since 1.8 + */ + @Override + public String getCalendarType() { + return "gregory"; + } + + /** * Compares this <code>GregorianCalendar</code> to the specified * <code>Object</code>. The result is <code>true</code> if and * only if the argument is a <code>GregorianCalendar</code> object * that represents the same time value (millisecond offset from * the <a href="Calendar.html#Epoch">Epoch</a>) under the same
*** 2918,2928 **** /** * Returns the Julian calendar system instance (singleton). 'jcal' * and 'jeras' are set upon the return. */ ! synchronized private static BaseCalendar getJulianCalendarSystem() { if (jcal == null) { jcal = (JulianCalendar) CalendarSystem.forName("julian"); jeras = jcal.getEras(); } return jcal; --- 2931,2941 ---- /** * Returns the Julian calendar system instance (singleton). 'jcal' * and 'jeras' are set upon the return. */ ! private static synchronized BaseCalendar getJulianCalendarSystem() { if (jcal == null) { jcal = (JulianCalendar) CalendarSystem.forName("julian"); jeras = jcal.getEras(); } return jcal;
*** 2942,2952 **** /** * Determines if the specified year (normalized) is the Gregorian * cutover year. This object must have been normalized. */ ! private final boolean isCutoverYear(int normalizedYear) { int cutoverYear = (calsys == gcal) ? gregorianCutoverYear : gregorianCutoverYearJulian; return normalizedYear == cutoverYear; } /** --- 2955,2965 ---- /** * Determines if the specified year (normalized) is the Gregorian * cutover year. This object must have been normalized. */ ! private boolean isCutoverYear(int normalizedYear) { int cutoverYear = (calsys == gcal) ? gregorianCutoverYear : gregorianCutoverYearJulian; return normalizedYear == cutoverYear; } /**
*** 2969,2980 **** // cutover date as the first day of the year. return gregorianCutoverDate; } } // January 1 of the normalized year should exist. ! BaseCalendar jcal = getJulianCalendarSystem(); ! return jcal.getFixedDate(date.getNormalizedYear(), BaseCalendar.JANUARY, 1, null); } /** * Returns the fixed date of the first date of the month (usually * the 1st of the month) before the specified date. --- 2982,2993 ---- // cutover date as the first day of the year. return gregorianCutoverDate; } } // January 1 of the normalized year should exist. ! BaseCalendar juliancal = getJulianCalendarSystem(); ! return juliancal.getFixedDate(date.getNormalizedYear(), BaseCalendar.JANUARY, 1, null); } /** * Returns the fixed date of the first date of the month (usually * the 1st of the month) before the specified date.