Package java.text

Examples of java.text.DecimalFormatSymbols


    public void writePDF( OutputStream output ) throws IOException
    {
        DecimalFormat formatDecimal = (DecimalFormat)NumberFormat.getNumberInstance();
        formatDecimal.setMaximumFractionDigits( 10 );
        formatDecimal.setGroupingUsed( false );
        DecimalFormatSymbols symbols = formatDecimal.getDecimalFormatSymbols();
        symbols.setDecimalSeparator( '.' );
        formatDecimal.setDecimalFormatSymbols( symbols );
        output.write(formatDecimal.format( value ).getBytes());
    }
View Full Code Here


            return (int)((RubyFixnum)obj).getLongValue();
        }
       
        final byte getDecimalSeparator() {
            // not saving DFS instance, as it will only be used once (at most) per call
            return (byte)new DecimalFormatSymbols(locale).getDecimalSeparator();
        }
View Full Code Here

    HashMap locales = _formatNumberFun.getLocales();
    iter = locales.keySet().iterator();
    while (iter.hasNext()) {
      String name = (String) iter.next();
      DecimalFormatSymbols symbols = (DecimalFormatSymbols) locales.get(name);

      out.println("symbols = new java.text.DecimalFormatSymbols();");
     
      out.print("symbols.setDecimalSeparator(\'");
      out.printJavaChar(symbols.getDecimalSeparator());
      out.println("\');");
     
      out.print("symbols.setGroupingSeparator(\'");
      out.printJavaChar(symbols.getGroupingSeparator());
      out.println("\');");
     
      out.print("symbols.setInfinity(\"");
      out.printJavaString(symbols.getInfinity());
      out.println("\");");
     
      out.print("symbols.setMinusSign(\'");
      out.printJavaChar(symbols.getMinusSign());
      out.println("\');");
     
      out.print("symbols.setNaN(\"");
      out.printJavaString(symbols.getNaN());
      out.println("\");");
     
      out.print("symbols.setPercent(\'");
      out.printJavaChar(symbols.getPercent());
      out.println("\');");
     
      out.print("symbols.setPerMill(\'");
      out.printJavaChar(symbols.getPerMill());
      out.println("\');");
     
      out.print("symbols.setZeroDigit(\'");
      out.printJavaChar(symbols.getZeroDigit());
      out.println("\');");
     
      out.print("symbols.setDigit(\'");
      out.printJavaChar(symbols.getDigit());
      out.println("\');");
     
      out.print("symbols.setPatternSeparator(\'");
      out.printJavaChar(symbols.getPatternSeparator());
      out.println("\');");

      println("formatFun.addLocale(\"" + name + "\", symbols);");
    }
   
View Full Code Here

  {
    String name = element.getAttribute("name");
    if (name.equals(""))
      name = "*";

    DecimalFormatSymbols format = new DecimalFormatSymbols();

    String value = element.getAttribute("decimal-separator");
    if (value.length() > 0)
      format.setDecimalSeparator(value.charAt(0));

    value = element.getAttribute("grouping-separator");
    if (value.length() > 0)
      format.setGroupingSeparator(value.charAt(0));

    value = element.getAttribute("infinity");
    if (! value.equals(""))
      format.setInfinity(value);

    value = element.getAttribute("minus-sign");
    if (value.length() > 0)
      format.setMinusSign(value.charAt(0));

    value = element.getAttribute("NaN");
    if (! value.equals(""))
      format.setNaN(value);

    value = element.getAttribute("percent");
    if (value.length() > 0)
      format.setPercent(value.charAt(0));

    value = element.getAttribute("per-mille");
    if (value.length() > 0)
      format.setPerMill(value.charAt(0));

    value = element.getAttribute("zero-digit");
    if (value.length() > 0)
      format.setZeroDigit(value.charAt(0));

    value = element.getAttribute("digit");
    if (value.length() > 0)
      format.setDigit(value.charAt(0));

    value = element.getAttribute("pattern-separator");
    if (value.length() > 0)
      format.setPatternSeparator(value.charAt(0));

    _formatNumberFun.addLocale(name, format);
  }
View Full Code Here

        format = NumberFormat.getCurrencyInstance();

      if ((_currencyCode != null || _currencySymbol != null)
          && format instanceof DecimalFormat) {
        DecimalFormat dFormat = (DecimalFormat) format;
        DecimalFormatSymbols dSymbols;

        dSymbols = dFormat.getDecimalFormatSymbols();

        if (_currencyCode != null && dSymbols != null)
          dSymbols.setInternationalCurrencySymbol(_currencyCode);
        else if (_currencySymbol != null && dSymbols != null)
          dSymbols.setCurrencySymbol(_currencySymbol);

        dFormat.setDecimalFormatSymbols(dSymbols);
      }
    }
    else
View Full Code Here

          format = NumberFormat.getCurrencyInstance();

        if ((_currencyCodeExpr != null || _currencySymbolExpr != null) &&
            format instanceof DecimalFormat) {
          DecimalFormat dFormat = (DecimalFormat) format;
          DecimalFormatSymbols dSymbols;

          dSymbols = dFormat.getDecimalFormatSymbols();

          if (_currencyCodeExpr != null && dSymbols != null)
            dSymbols.setInternationalCurrencySymbol(_currencyCodeExpr.evalString(env));

          if (_currencySymbolExpr != null && dSymbols != null)
            dSymbols.setCurrencySymbol(_currencySymbolExpr.evalString(env));

          dFormat.setDecimalFormatSymbols(dSymbols);
        }
      }
      else
View Full Code Here

        assertEquals("Test key", "42", context.getValue("key('a', 'b')"));
    }
   
    public void testFormatNumberFunction() {
       
        DecimalFormatSymbols symbols = new DecimalFormatSymbols();
        symbols.setDigit('D');
       
        context.setDecimalFormatSymbols("test", symbols);
       
        assertXPathValue(
            context,
View Full Code Here

        double number =
            InfoSetUtil.doubleValue(getArg1().computeValue(context));
        String pattern =
            InfoSetUtil.stringValue(getArg2().computeValue(context));

        DecimalFormatSymbols symbols = null;
        if (ac == 3) {
            String symbolsName =
                InfoSetUtil.stringValue(getArg3().computeValue(context));
            symbols =
                context.getJXPathContext().getDecimalFormatSymbols(symbolsName);
        }
        else {
            NodePointer pointer = context.getCurrentNodePointer();
            Locale locale;
            if (pointer != null) {
                locale = pointer.getLocale();
            }
            else {
                locale = context.getJXPathContext().getLocale();
            }
            symbols = new DecimalFormatSymbols(locale);
        }
       
        DecimalFormat format = (DecimalFormat) NumberFormat.getInstance();
        format.setDecimalFormatSymbols(symbols);
        format.applyLocalizedPattern(pattern);
View Full Code Here

     */
    protected final BigDecimal canonicalizeDecimalInput(String bigDecimal)
    {
        if (getLocale() != null)
        {
            DecimalFormatSymbols internal = new DecimalFormatSymbols();
            DecimalFormatSymbols user = new DecimalFormatSymbols(getLocale());

            if (!internal.equals(user))
            {
                bigDecimal = bigDecimal.replace(user.getDecimalSeparator(),
                        internal.getDecimalSeparator());
            }
        }
        return new BigDecimal(bigDecimal);
    }
View Full Code Here

            String rxNotDigits = "[^0-9]";
            StringBuilder builder = new StringBuilder(value.length());

            // override defaults according to numberFormat's settings
            if (numberFormat() instanceof DecimalFormat) {
                DecimalFormatSymbols decimalFormatSymbols = ((DecimalFormat) numberFormat()).getDecimalFormatSymbols();
                minusSign = decimalFormatSymbols.getMinusSign();
                decimalPointSeparator = decimalFormatSymbols.getDecimalSeparator();
            }

            value = value.trim();
            int decimalPointPosition = value.lastIndexOf(decimalPointSeparator);
            boolean isNegative = value.charAt(0) == minusSign;
View Full Code Here

TOP

Related Classes of java.text.DecimalFormatSymbols

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.