Print this page
rev 5696 : 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 packaging changes. by Naoto Sato and Masayoshi Okutsu)

Split Close
Expand all
Collapse all
          --- old/src/share/classes/java/util/GregorianCalendar.java
          +++ new/src/share/classes/java/util/GregorianCalendar.java
   1    1  /*
   2      - * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
        2 + * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
   3    3   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4    4   *
   5    5   * This code is free software; you can redistribute it and/or modify it
   6    6   * under the terms of the GNU General Public License version 2 only, as
   7    7   * published by the Free Software Foundation.  Oracle designates this
   8    8   * particular file as subject to the "Classpath" exception as provided
   9    9   * by Oracle in the LICENSE file that accompanied this code.
  10   10   *
  11   11   * This code is distributed in the hope that it will be useful, but WITHOUT
  12   12   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
↓ open down ↓ 20 lines elided ↑ open up ↑
  33   33   * and Sun. This technology is protected by multiple US and International
  34   34   * patents. This notice and attribution to Taligent may not be removed.
  35   35   *   Taligent is a registered trademark of Taligent, Inc.
  36   36   *
  37   37   */
  38   38  
  39   39  package java.util;
  40   40  
  41   41  import java.io.IOException;
  42   42  import java.io.ObjectInputStream;
       43 +import sun.util.locale.provider.CalendarDataUtility;
  43   44  import sun.util.calendar.BaseCalendar;
  44   45  import sun.util.calendar.CalendarDate;
  45   46  import sun.util.calendar.CalendarSystem;
  46   47  import sun.util.calendar.CalendarUtils;
  47   48  import sun.util.calendar.Era;
  48   49  import sun.util.calendar.Gregorian;
  49   50  import sun.util.calendar.JulianCalendar;
  50   51  import sun.util.calendar.ZoneInfo;
  51   52  
  52   53  /**
↓ open down ↓ 432 lines elided ↑ open up ↑
 485  486          11,             // HOUR
 486  487          23,             // HOUR_OF_DAY
 487  488          59,             // MINUTE
 488  489          59,             // SECOND
 489  490          999,            // MILLISECOND
 490  491          14*ONE_HOUR,    // ZONE_OFFSET
 491  492          2*ONE_HOUR      // DST_OFFSET (double summer time)
 492  493      };
 493  494  
 494  495      // Proclaim serialization compatibility with JDK 1.1
      496 +    @SuppressWarnings("FieldNameHidesFieldInSuperclass")
 495  497      static final long serialVersionUID = -8125100834729963327L;
 496  498  
 497  499      // Reference to the sun.util.calendar.Gregorian instance (singleton).
 498  500      private static final Gregorian gcal =
 499  501                                  CalendarSystem.getGregorianCalendar();
 500  502  
 501  503      // Reference to the JulianCalendar instance (singleton), set as needed. See
 502  504      // getJulianCalendarSystem().
 503  505      private static JulianCalendar jcal;
 504  506  
↓ open down ↓ 253 lines elided ↑ open up ↑
 758  760          // a pure Julian calendar. (See 4167995)
 759  761          if (cutoverTime == Long.MAX_VALUE) {
 760  762              gregorianCutoverDate++;
 761  763          }
 762  764  
 763  765          BaseCalendar.Date d = getGregorianCutoverDate();
 764  766  
 765  767          // Set the cutover year (in the Gregorian year numbering)
 766  768          gregorianCutoverYear = d.getYear();
 767  769  
 768      -        BaseCalendar jcal = getJulianCalendarSystem();
 769      -        d = (BaseCalendar.Date) jcal.newCalendarDate(TimeZone.NO_TIMEZONE);
 770      -        jcal.getCalendarDateFromFixedDate(d, gregorianCutoverDate - 1);
      770 +        BaseCalendar julianCal = getJulianCalendarSystem();
      771 +        d = (BaseCalendar.Date) julianCal.newCalendarDate(TimeZone.NO_TIMEZONE);
      772 +        julianCal.getCalendarDateFromFixedDate(d, gregorianCutoverDate - 1);
 771  773          gregorianCutoverYearJulian = d.getNormalizedYear();
 772  774  
 773  775          if (time < gregorianCutover) {
 774  776              // The field values are no longer valid under the new
 775  777              // cutover date.
 776  778              setUnnormalized();
 777  779          }
 778  780      }
 779  781  
 780  782      /**
↓ open down ↓ 34 lines elided ↑ open up ↑
 815  817          if (gregorianCutoverYear == gregorianCutoverYearJulian) {
 816  818              BaseCalendar.Date d = getCalendarDate(gregorianCutoverDate); // Gregorian
 817  819              gregorian = d.getMonth() < BaseCalendar.MARCH;
 818  820          } else {
 819  821              gregorian = year == gregorianCutoverYear;
 820  822          }
 821  823          return gregorian ? (year%100 != 0) || (year%400 == 0) : true;
 822  824      }
 823  825  
 824  826      /**
      827 +     * Returns {@code "gregory"} as the calendar type.
      828 +     *
      829 +     * @return {@code "gregory"}
      830 +     * @since 1.8
      831 +     */
      832 +    @Override
      833 +    public String getCalendarType() {
      834 +        return "gregory";
      835 +    }
      836 +
      837 +    /**
 825  838       * Compares this <code>GregorianCalendar</code> to the specified
 826  839       * <code>Object</code>. The result is <code>true</code> if and
 827  840       * only if the argument is a <code>GregorianCalendar</code> object
 828  841       * that represents the same time value (millisecond offset from
 829  842       * the <a href="Calendar.html#Epoch">Epoch</a>) under the same
 830  843       * <code>Calendar</code> parameters and Gregorian change date as
 831  844       * this object.
 832  845       *
 833  846       * @param obj the object to compare with.
 834  847       * @return <code>true</code> if this object is equal to <code>obj</code>;
↓ open down ↓ 105 lines elided ↑ open up ↑
 940  953                          set(YEAR, year);
 941  954                      } else { // year <= 0
 942  955                          set(YEAR, 1 - year);
 943  956                          // if year == 0, you get 1 CE
 944  957                          set(ERA, CE);
 945  958                      }
 946  959                  }
 947  960              }
 948  961  
 949  962              if (month >= 0) {
 950      -                set(MONTH, month % 12);
      963 +                set(MONTH,  month % 12);
 951  964              } else {
 952  965                  // month < 0
 953  966                  month %= 12;
 954  967                  if (month < 0) {
 955  968                      month += 12;
 956  969                  }
 957  970                  set(MONTH, JANUARY + month);
 958  971              }
 959  972              pinDayOfMonth();
 960  973          } else if (field == ERA) {
↓ open down ↓ 1952 lines elided ↑ open up ↑
2913 2926              gc.setLenient(true);
2914 2927              gc.complete();
2915 2928          }
2916 2929          return gc;
2917 2930      }
2918 2931  
2919 2932      /**
2920 2933       * Returns the Julian calendar system instance (singleton). 'jcal'
2921 2934       * and 'jeras' are set upon the return.
2922 2935       */
2923      -    synchronized private static BaseCalendar getJulianCalendarSystem() {
     2936 +    private static synchronized BaseCalendar getJulianCalendarSystem() {
2924 2937          if (jcal == null) {
2925 2938              jcal = (JulianCalendar) CalendarSystem.forName("julian");
2926 2939              jeras = jcal.getEras();
2927 2940          }
2928 2941          return jcal;
2929 2942      }
2930 2943  
2931 2944      /**
2932 2945       * Returns the calendar system for dates before the cutover date
2933 2946       * in the cutover year. If the cutover date is January 1, the
↓ open down ↓ 3 lines elided ↑ open up ↑
2937 2950          if (gregorianCutoverYearJulian < gregorianCutoverYear) {
2938 2951              return gcal;
2939 2952          }
2940 2953          return getJulianCalendarSystem();
2941 2954      }
2942 2955  
2943 2956      /**
2944 2957       * Determines if the specified year (normalized) is the Gregorian
2945 2958       * cutover year. This object must have been normalized.
2946 2959       */
2947      -    private final boolean isCutoverYear(int normalizedYear) {
     2960 +    private boolean isCutoverYear(int normalizedYear) {
2948 2961          int cutoverYear = (calsys == gcal) ? gregorianCutoverYear : gregorianCutoverYearJulian;
2949 2962          return normalizedYear == cutoverYear;
2950 2963      }
2951 2964  
2952 2965      /**
2953 2966       * Returns the fixed date of the first day of the year (usually
2954 2967       * January 1) before the specified date.
2955 2968       *
2956 2969       * @param date the date for which the first day of the year is
2957 2970       * calculated. The date has to be in the cut-over year (Gregorian
↓ open down ↓ 6 lines elided ↑ open up ↑
2964 2977          if (gregorianCutoverYear != gregorianCutoverYearJulian) {
2965 2978              if (fixedDate >= gregorianCutoverDate) {
2966 2979                  // Dates before the cutover date don't exist
2967 2980                  // in the same (Gregorian) year. So, no
2968 2981                  // January 1 exists in the year. Use the
2969 2982                  // cutover date as the first day of the year.
2970 2983                  return gregorianCutoverDate;
2971 2984              }
2972 2985          }
2973 2986          // January 1 of the normalized year should exist.
2974      -        BaseCalendar jcal = getJulianCalendarSystem();
2975      -        return jcal.getFixedDate(date.getNormalizedYear(), BaseCalendar.JANUARY, 1, null);
     2987 +        BaseCalendar juliancal = getJulianCalendarSystem();
     2988 +        return juliancal.getFixedDate(date.getNormalizedYear(), BaseCalendar.JANUARY, 1, null);
2976 2989      }
2977 2990  
2978 2991      /**
2979 2992       * Returns the fixed date of the first date of the month (usually
2980 2993       * the 1st of the month) before the specified date.
2981 2994       *
2982 2995       * @param date the date for which the first day of the month is
2983 2996       * calculated. The date has to be in the cut-over year (Gregorian
2984 2997       * or Julian).
2985 2998       * @param fixedDate the fixed date representation of the date
↓ open down ↓ 194 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX