Package java.text

Examples of java.text.DecimalFormat.applyPattern()


    }

    public static String format(final long number, final String conversionPattern) {
        DecimalFormat df = DECIMAL_FORMAT.get();
        if (conversionPattern != null) {
            df.applyPattern(conversionPattern);
        }
        return df.format(number);
    }

    public static String format(final double number) {
View Full Code Here


    }

    public static String format(final double number, final String conversionPattern) {
        DecimalFormat df = DECIMAL_FORMAT.get();
        if (conversionPattern != null) {
            df.applyPattern(conversionPattern);
        }
        return df.format(number);
    }

    public static Date parseDate(final String source) throws ParseException {
View Full Code Here

        return sdf.parse(source);
    }

    public static Number parseNumber(final String source, final String conversionPattern) throws ParseException {
        DecimalFormat df = DECIMAL_FORMAT.get();
        df.applyPattern(conversionPattern);
        return df.parse(source);
    }

    public static void clear() {
        DATE_FORMAT.remove();
View Full Code Here

      result = (DecimalFormat)format;
    }
    else {
      throw new AssertionError();
    }
    result.applyPattern(aFormat);
    return result;
  }
 
  private static void vomit(String aMessage){
    fLogger.severe(aMessage);
View Full Code Here

        // the constructor form that specifies a pattern is equal to the form
        // constructed with no pattern and applying that pattern using the
        // applyPattern call
        DecimalFormat format = new DecimalFormat("'$'0000.0000");
        DecimalFormat format1 = new DecimalFormat();
        format1.applyPattern("'$'0000.0000");
        assertTrue("Constructed format did not match applied format object",
                format.equals(format1));
    }

    /**
 
View Full Code Here

        DecimalFormat format1 = (DecimalFormat) (format.clone());
        // make sure the objects are equal
        assertTrue("Object's clone isn't equal!", format.equals(format1));
        // change the content of the clone and make sure it's not equal anymore
        // verifies that it's data is now distinct from the original
        format1.applyPattern("'$'0000.####");
        assertTrue("Object's changed clone should not be equal!", !format
                .equals(format1));
    }

    private void compare(String testName, String format, String expected) {
View Full Code Here

        // the constructor form that specifies a pattern is equal to the form
        // constructed with no pattern and applying that pattern using the
        // applyPattern call
        DecimalFormat format = new DecimalFormat("'$'0000.0000");
        DecimalFormat format1 = new DecimalFormat();
        format1.applyPattern("'$'0000.0000");
        assertTrue("Constructed format did not match applied format object",
                format.equals(format1));
    }

    /**
 
View Full Code Here

        DecimalFormat format1 = (DecimalFormat) (format.clone());
        // make sure the objects are equal
        assertTrue("Object's clone isn't equal!", format.equals(format1));
        // change the content of the clone and make sure it's not equal anymore
        // verifies that it's data is now distinct from the original
        format1.applyPattern("'$'0000.####");
        assertTrue("Object's changed clone should not be equal!", !format
                .equals(format1));
    }

    private void compare(String testName, String format, String expected) {
View Full Code Here

            for (int i = 0; i < pattern.length(); i++) {
                if (pattern.charAt(i) != PERCENT_SYMBOL) {
                    buffer.append(pattern.charAt(i));
                }
            }
            decimalFormat.applyPattern(buffer.toString());
            parsedValue = (BigDecimal)super.parse(value, decimalFormat);
           
            // If parsed OK, divide by 100 to get percent
            if (parsedValue != null) {
                parsedValue = parsedValue.multiply(POINT_ZERO_ONE);
View Full Code Here

        DecimalFormat from_fmt = (DecimalFormat)NumberFormat.getInstance(srcLoc);
        int int_currency = 0;

        // src-pattern overwrites locale format
        if (srcPattern != null) {
            from_fmt.applyPattern(srcPattern);
        }

        // to format
        DecimalFormat to_fmt = null;
        char dec = from_fmt.getDecimalFormatSymbols().getDecimalSeparator();
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.