コード例 #1
0
 /**
  * Constructor.
  *
  * @param locale the locale of the culture, not null
  * @param zeroChar the character to use for the digit of zero
  * @param positiveSignChar the character to use for the positive sign
  * @param negativeSignChar the character to use for the negative sign
  * @param decimalPointChar the character to use for the decimal point
  * @param firstDayOfWeek the first day of the week
  * @param minDaysInFirstWeek the minimum number of days in the first week, 1 to 7
  */
 public DateTimeFormatSymbols(
     Locale locale,
     char zeroChar,
     char positiveSignChar,
     char negativeSignChar,
     char decimalPointChar,
     DayOfWeek firstDayOfWeek,
     int minDaysInFirstWeek) {
   DateTimeFormatter.checkNotNull(locale, "Locale must not be null");
   DateTimeFormatter.checkNotNull(firstDayOfWeek, "DayOfWeek must not be null");
   this.locale = locale;
   this.zeroDigit = zeroChar;
   this.positiveSign = positiveSignChar;
   this.negativeSign = negativeSignChar;
   this.decimalSeparator = decimalPointChar;
   this.firstDayOfWeek = firstDayOfWeek;
   this.minDaysInFirstWeek = minDaysInFirstWeek;
 }
コード例 #2
0
 /**
  * Obtains an info for the specified locale.
  *
  * <p>This method provides access to locale sensitive information.
  *
  * @param locale the locale, not null
  * @return the info, not null
  */
 public static DateTimeFormatSymbols of(Locale locale) {
   DateTimeFormatter.checkNotNull(locale, "Locale must not be null");
   DateTimeFormatSymbols info = CACHE.get(locale);
   if (info == null) {
     info = createInfo(locale);
     CACHE.putIfAbsent(locale, info);
     info = CACHE.get(locale);
   }
   return info;
 }
コード例 #3
0
  private static DateTimeFormatSymbols createInfo(Locale locale) {
    DecimalFormatSymbols oldSymbols = DecimalFormatSymbols.getInstance(locale);
    DateTimeFormatter.checkNotNull(oldSymbols, "Symbols to convert must not be null");
    char zeroDigit = oldSymbols.getZeroDigit();
    char positiveSign = '+';
    char negativeSign = oldSymbols.getMinusSign();
    char decimalSeparator = oldSymbols.getDecimalSeparator();

    Calendar cal = Calendar.getInstance(locale);
    int calFDoW = cal.getFirstDayOfWeek();
    DayOfWeek firstDayOfWeek = (calFDoW == 1 ? DayOfWeek.SUNDAY : DayOfWeek.of(calFDoW - 1));
    int minDaysInFirstWeek = cal.getMinimalDaysInFirstWeek();

    return new DateTimeFormatSymbols(
        locale,
        zeroDigit,
        positiveSign,
        negativeSign,
        decimalSeparator,
        firstDayOfWeek,
        minDaysInFirstWeek);
  }