Package java.text

Examples of java.text.DecimalFormatSymbols


    DecimalFormat dfDouble;

    public RouteCellRenderer() {
        df = new DecimalFormat("#,##0");
        dfDouble = new DecimalFormat("#,##0.00");
        DecimalFormatSymbols dfs = df.getDecimalFormatSymbols();
        dfs.setDecimalSeparator('.');
        dfs.setGroupingSeparator(',');
        df.setDecimalFormatSymbols(dfs);

        dfs = dfDouble.getDecimalFormatSymbols();
        dfs.setDecimalSeparator('.');
        dfs.setGroupingSeparator(',');
        dfDouble.setDecimalFormatSymbols(dfs);
    }
View Full Code Here


      return valueOf("N/A");
    }
    else
    {
      final DecimalFormat format = new DecimalFormat("#." + repeat(places, '#'),
        new DecimalFormatSymbols(locale));
      return valueOf(format.format(value));
    }
  }
View Full Code Here

    Field bogus2 = newField("zbogus2", "", Field.Store.NO, Field.Index.NOT_ANALYZED_NO_NORMS);
    doc.add(field);
    doc.add(bogus1);
    doc.add(bogus2);
   
    NumberFormat df = new DecimalFormat("000", new DecimalFormatSymbols(Locale.ENGLISH));
    for (int i = 0; i < 1000; i++) {
      field.setValue(df.format(i));
      bogus1.setValue(_TestUtil.randomUnicodeString(random, 10));
      bogus2.setValue(_TestUtil.randomUnicodeString(random, 10));
      writer.addDocument(doc);
View Full Code Here

    Directory directory = newDirectory();
    RandomIndexWriter writer = new RandomIndexWriter(random, directory,
        newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random))
        .setMaxBufferedDocs(_TestUtil.nextInt(random, 50, 1000)));
   
    DecimalFormat format = new DecimalFormat("00000000000", new DecimalFormatSymbols(Locale.US));
   
    int num = atLeast(500);
    for (int l = 0; l < num; l++) {
      Document doc = new Document();
      for (int m=0, c=random.nextInt(10); m<=c; m++) {
View Full Code Here

      return valueOf("N/A");
    }
    else
    {
      final DecimalFormat format = new DecimalFormat("#." + repeat(places, '#'),
        new DecimalFormatSymbols(locale));
      return valueOf(format.format(value));
    }
  }
View Full Code Here

   * string is null, zero length, or otherwise
   * malformed.
   */
public PrintfFormat(Locale locale,String fmtArg)
      throws IllegalArgumentException {
    dfs = new DecimalFormatSymbols(locale);
    int ePos=0;
    ConversionSpecification sFmt=null;
    String unCS = this.nonControl(fmtArg,0);
    if (unCS!=null) {
      sFmt = new ConversionSpecification();
View Full Code Here

     *@throws  SAXException  iff SAX generation fails.
     */
    protected void generateSVGLineElements() throws SAXException {
        //NumberFormat nf = NumberFormat.getInstance(Locale.US);
        //nf.setGroupingIsUsed( false );
        DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US);
        DecimalFormat df = new DecimalFormat("##0.0##", dfs);
        Iterator i = asciiArtPad.iterator();
        while (i.hasNext()) {
            Object o = i.next();
            if (o instanceof AsciiArtPad.AsciiArtLine) {
View Full Code Here

     *
     *@throws  SAXException  iff SAX generation fails.
     */
    protected void generateSVGTextElements() throws SAXException {
        //NumberFormat nf = NumberFormat.getInstance(Locale.US);
        DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US);
        DecimalFormat df = new DecimalFormat("##0.0##", dfs);
        Iterator i = asciiArtPad.iterator();
        while (i.hasNext()) {
            Object o = i.next();
            if (o instanceof AsciiArtPad.AsciiArtString) {
View Full Code Here

    NumberFormat fmt = _getNumberFormat(pattern, type, locale, reqCtx);
   
    DecimalFormat df = (DecimalFormat)fmt;
    df.setParseBigDecimal(true); // TODO What does this do?
    DecimalFormatSymbols dfs = df.getDecimalFormatSymbols();
   
    // We change the grouping_separator b/c TRINIDAD-849
    // source is this JDK bug: 4510618.
    boolean changed = false;
    if (dfs.getGroupingSeparator() == '\u00a0')
    {
      // In some locales, such as fr_FR, the grouping separator is '\u00a0', a
      // non-breaking space. However, users will normally enter a regular space
      // character into an input field, so in order for the input to be parsed
      // correctly, we set the grouping separator to a regular space character.
      dfs.setGroupingSeparator(' ');
      df.setDecimalFormatSymbols(dfs);
     
      // In the (rare) case that the user actually enters a non-breaking space,
      // we replace it with a regular space. This should be fine, since the
      // percent format for fr_FR is " %" (regular space followed by percent).
      value = value.replace('\u00a0', ' ');
     
      changed = true;
    }
   
    ParsePosition pp = new ParsePosition(0)
    Number num = (Number)fmt.parseObject(value, pp);  
   
    // The following determines whether the percent/currency symbol was left off.
    int typeIdx = _getType(pattern, type);
    if (num == null && (typeIdx == _CURRENCY_TYPE || typeIdx == _PERCENT_TYPE))
    {
      // For parsing 'value' as a Number when the percent/currency symbol is left off.
      NumberFormat nfmt = NumberFormat.getNumberInstance(locale);
      DecimalFormat ndf = (DecimalFormat)nfmt;
      ndf.setParseBigDecimal(true); // TODO What does this do?
      DecimalFormatSymbols ndfs = null;
     
      if (changed)
      {
        ndfs = ndf.getDecimalFormatSymbols();
        ndfs.setGroupingSeparator(' ');
        ndf.setDecimalFormatSymbols(ndfs);
      }
     
      // Assume the percent/currency symbol was left off, in which case we should
      // be able to parse 'value' as a Number.
View Full Code Here

    if (nfmt instanceof DecimalFormat)
    {
      DecimalFormat dfmt = (DecimalFormat)nfmt;

      // what we get here is a shallow copy. cloned DFS
      DecimalFormatSymbols dfSymbols = dfmt.getDecimalFormatSymbols();

      _setUpDecimalSymbolFormatProperties(dfSymbols, reqCtx, locale);

      //since we get a shallow copy - setting it again after modification.
      ((DecimalFormat) nfmt).setDecimalFormatSymbols(dfSymbols);
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.