Package java.text

Examples of java.text.DecimalFormat.toPattern()


  {
    final SimpleDateFormat dfmt = new SimpleDateFormat("");
    System.out.println(dfmt.toPattern());

    final DecimalFormat dcfmt = new DecimalFormat(DECIMALFORMAT_DEFAULT_PATTERN);
    System.out.println(dcfmt.toPattern());

    testSerialization(dfmt);
    testSerialization(dcfmt);
  }
}
View Full Code Here


      throws ObjectFactoryException
  {
    super.setParameterFromObject(o);
    final DecimalFormat format = (DecimalFormat) o;
    //setParameter("localizedPattern", format.toLocalizedPattern());
    setParameter("pattern", format.toPattern());
  }

  /**
   * Creates an object (<code>DecimalFormat</code>) based on this description.
   *
 
View Full Code Here

      {
        final NumberFormat format = NumberFormat.getCurrencyInstance(context.getLocale());
        if (format instanceof DecimalFormat)
        {
          final DecimalFormat decimalFormat = (DecimalFormat) format;
          return decimalFormat.toPattern();
        }
      }

      final DecimalFormat format = new DecimalFormat();
      if (scale != null && precision != null)
View Full Code Here

        format.setMaximumFractionDigits(scale.intValue());
        format.setMinimumFractionDigits(scale.intValue());
        format.setMaximumIntegerDigits(precision.intValue() - scale.intValue());
        format.setMinimumIntegerDigits(1);
      }
      return format.toPattern();
    }
    return null;
  }

  public static boolean isIgnorable(final DataAttributes attributes,
View Full Code Here

  public String getFormatString()
  {
    if (getFormat() instanceof DecimalFormat)
    {
      final DecimalFormat decFormat = (DecimalFormat) getFormat();
      return decFormat.toPattern();
    }
    return null;
  }

  /**
 
View Full Code Here

        element.setAttributeExpression(AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, formulaExpression);
      }
      if (format != null)
      {
        final DecimalFormat decimalFormat = (DecimalFormat) format;
        final String formatString = decimalFormat.toPattern();
        element.setAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.FORMAT_STRING, formatString);
      }
      element.setAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.NULL_VALUE, getNullString());
    }
    else
View Full Code Here

                lformatdigits.setEnabled(true);
                if (((Object[])currentAction.option)[1] instanceof DecimalFormat) {
                  DecimalFormat df = ((DecimalFormat)((Object[])currentAction.option)[1]);
                  if (format==1) nfformat.setValue(df.getMaximumFractionDigits());
                  else {
                    String pattern = df.toPattern();
                    int l =0;
                    l = pattern.indexOf('E') - pattern.indexOf('.');
                    if (l>0) l--; // number of characters between . and E
                    nfformat.setValue(l);
                  }
View Full Code Here

            return parsedValue;
        }

        // Re-parse using a pattern without the currency symbol
        DecimalFormat decimalFormat = (DecimalFormat)formatter;
        String pattern = decimalFormat.toPattern();
        if (pattern.indexOf(CURRENCY_SYMBOL) >= 0) {
            StringBuffer buffer = new StringBuffer(pattern.length());
            for (int i = 0; i < pattern.length(); i++) {
                if (pattern.charAt(i) != CURRENCY_SYMBOL) {
                    buffer.append(pattern.charAt(i));
View Full Code Here

    /**
     * @tests java.text.DecimalFormat#applyPattern(java.lang.String)
     */
    public void test_applyPatternLjava_lang_String() {
        DecimalFormat format = new DecimalFormat("#.#");
        assertEquals("Wrong pattern 1", "#0.#", format.toPattern());
        format = new DecimalFormat("#.");
        assertEquals("Wrong pattern 2", "#0.", format.toPattern());
        format = new DecimalFormat("#");
        assertEquals("Wrong pattern 3", "#", format.toPattern());
        format = new DecimalFormat(".#");
View Full Code Here

     */
    public void test_applyPatternLjava_lang_String() {
        DecimalFormat format = new DecimalFormat("#.#");
        assertEquals("Wrong pattern 1", "#0.#", format.toPattern());
        format = new DecimalFormat("#.");
        assertEquals("Wrong pattern 2", "#0.", format.toPattern());
        format = new DecimalFormat("#");
        assertEquals("Wrong pattern 3", "#", format.toPattern());
        format = new DecimalFormat(".#");
        assertEquals("Wrong pattern 4", "#.0", format.toPattern());
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.