Example #1
0
  private static void describeDecimalFormatSymbols(StringBuilder result, DecimalFormatSymbols dfs) {
    result.append("Currency Symbol: " + unicodeString(dfs.getCurrencySymbol()) + "\n");
    result.append(
        "International Currency Symbol: "
            + unicodeString(dfs.getInternationalCurrencySymbol())
            + "\n");
    result.append("<p>");

    result.append("Digit: " + unicodeString(dfs.getDigit()) + "\n");
    result.append("Pattern Separator: " + unicodeString(dfs.getPatternSeparator()) + "\n");
    result.append("<p>");

    result.append("Decimal Separator: " + unicodeString(dfs.getDecimalSeparator()) + "\n");
    result.append(
        "Monetary Decimal Separator: " + unicodeString(dfs.getMonetaryDecimalSeparator()) + "\n");
    // 1.6: result.append("Exponent Separator: " + dfs.getExponentSeparator() + "\n");
    result.append("Grouping Separator: " + unicodeString(dfs.getGroupingSeparator()) + "\n");

    result.append("Infinity: " + unicodeString(dfs.getInfinity()) + "\n");
    result.append("Minus Sign: " + unicodeString(dfs.getMinusSign()) + "\n");
    result.append("NaN: " + unicodeString(dfs.getNaN()) + "\n");
    result.append("Percent: " + unicodeString(dfs.getPercent()) + "\n");
    result.append("Per Mille: " + unicodeString(dfs.getPerMill()) + "\n");
    result.append("Zero Digit: " + unicodeString(dfs.getZeroDigit()) + "\n");
    StringBuilder digits = new StringBuilder();
    for (int i = 0; i <= 9; ++i) {
      digits.append((char) (dfs.getZeroDigit() + i));
    }
    result.append("Digits: " + digits.toString() + "\n");
    result.append("<p>");
    result.append("<p>");
  }
 static void assertDecimalFormatSymbolsRIFrance(DecimalFormatSymbols dfs) {
   // Values based on Java 1.5 RI DecimalFormatSymbols for Locale.FRANCE
   /*
    * currency = [EUR]
    * currencySymbol = [€][U+20ac]
    * decimalSeparator = [,][U+002c]
    * digit = [#][U+0023]
    * groupingSeparator = [ ][U+00a0]
    * infinity = [∞][U+221e]
    * internationalCurrencySymbol = [EUR]
    * minusSign = [-][U+002d]
    * monetaryDecimalSeparator = [,][U+002c]
    * naN = [�][U+fffd]
    * patternSeparator = [;][U+003b]
    * perMill = [‰][U+2030]
    * percent = [%][U+0025]
    * zeroDigit = [0][U+0030]
    */
   assertEquals("EUR", dfs.getCurrency().getCurrencyCode());
   assertEquals("\u20AC", dfs.getCurrencySymbol());
   assertEquals(',', dfs.getDecimalSeparator());
   assertEquals('#', dfs.getDigit());
   assertEquals('\u00a0', dfs.getGroupingSeparator());
   assertEquals("\u221e", dfs.getInfinity());
   assertEquals("EUR", dfs.getInternationalCurrencySymbol());
   assertEquals('-', dfs.getMinusSign());
   assertEquals(',', dfs.getMonetaryDecimalSeparator());
   // RI's default NaN is U+FFFD, Harmony's is based on ICU
   assertEquals("\uFFFD", dfs.getNaN());
   assertEquals('\u003b', dfs.getPatternSeparator());
   assertEquals('\u2030', dfs.getPerMill());
   assertEquals('%', dfs.getPercent());
   assertEquals('0', dfs.getZeroDigit());
 }
Example #3
0
 public static VerifyListener getNumberVerifyListener(Locale locale) {
   DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(locale);
   final char[] allowedChars =
       new char[] {
         symbols.getDecimalSeparator(),
         symbols.getGroupingSeparator(),
         symbols.getMinusSign(),
         symbols.getZeroDigit(),
         symbols.getMonetaryDecimalSeparator(),
         '+'
       };
   final String exponentSeparator = symbols.getExponentSeparator();
   return new VerifyListener() {
     @Override
     public void verifyText(VerifyEvent e) {
       for (int i = 0; i < e.text.length(); i++) {
         char ch = e.text.charAt(i);
         if (!Character.isDigit(ch)
             && !ArrayUtils.contains(allowedChars, ch)
             && exponentSeparator.indexOf(ch) == -1) {
           e.doit = false;
           return;
         }
       }
       e.doit = true;
     }
   };
 }
 /** @tests java.text.DecimalFormatSymbols#setZeroDigit(char) */
 @TestTargetNew(
     level = TestLevel.COMPLETE,
     notes = "",
     method = "setZeroDigit",
     args = {char.class})
 public void test_setZeroDigitC() {
   dfs.setZeroDigit('*');
   assertEquals("Set incorrect ZeroDigit symbol", '*', dfs.getZeroDigit());
 }
 /** @tests java.text.DecimalFormatSymbols#getZeroDigit() */
 @TestTargetNew(
     level = TestLevel.COMPLETE,
     notes = "",
     method = "getZeroDigit",
     args = {})
 public void test_getZeroDigit() {
   dfs.setZeroDigit('*');
   assertEquals("Returned incorrect ZeroDigit symbol", '*', dfs.getZeroDigit());
 }
  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);
  }