Package java.text

Examples of java.text.DecimalFormat.applyPattern()


      ".46", result);

    // set RoundingMode.HALF_EVEN of this DecimalFormat and test its
    // behavior
    decimalFormat.setRoundingMode(RoundingMode.HALF_EVEN);
    decimalFormat.applyPattern(".##");
    result = decimalFormat.format(0.125);
    assertEquals(
      "Incorrect RoundingMode behavior after applyPattern",
      ".12", result);
    result = decimalFormat.format(0.255);
View Full Code Here


    // Test with applyPattern call after setRoundingMode

    // set RoundingMode.HALF_UP of this DecimalFormat and test its
    // behavior
    decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
    decimalFormat.applyPattern(".##");
    result = decimalFormat.format(0.125);
    assertEquals(
      "Incorrect RoundingMode behavior after applyPattern",
      ".13", result);
    result = decimalFormat.format(0.255);
View Full Code Here

      ".47", result);

    // set RoundingMode.HALF_DOWN of this DecimalFormat and test its
    // behavior
    decimalFormat.setRoundingMode(RoundingMode.HALF_DOWN);
    decimalFormat.applyPattern(".##");
    result = decimalFormat.format(0.125);
    assertEquals(
      "Incorrect RoundingMode behavior after applyPattern",
      ".12", result);
    result = decimalFormat.format(0.255);
View Full Code Here

      ".47", result);

    // set RoundingMode.UP of this DecimalFormat and test its
    // behavior
    decimalFormat.setRoundingMode(RoundingMode.UP);
    decimalFormat.applyPattern(".##");
    result = decimalFormat.format(0.125);
    assertEquals(
      "Incorrect RoundingMode behavior after applyPattern",
      ".13", result);
    result = decimalFormat.format(0.255);
View Full Code Here

      ".47", result);

    // set RoundingMode.DOWN of this DecimalFormat and test its
    // behavior
    decimalFormat.setRoundingMode(RoundingMode.DOWN);
    decimalFormat.applyPattern(".##");
    result = decimalFormat.format(0.125);
    assertEquals(
      "Incorrect RoundingMode behavior after applyPattern",
      ".12", result);
    result = decimalFormat.format(0.255);
View Full Code Here

    if (_rounding != BigDecimal.ROUND_HALF_EVEN)
      df.setRoundingMode(RoundingMode.valueOf(_rounding));

    String fmt = getFormat();
    if (fmt == null) fmt = defaultFormat;
    if (fmt != null) df.applyPattern(fmt);
    return df.format(value);
  }
  /** Filters out non digit characters, such comma and whitespace,
   * from the specified value.
   * It is designed to let user enter data in more free style.
View Full Code Here

      return format;
    }
    DecimalFormat decimalFormat = (DecimalFormat) format;
    decimalFormat.setParseBigDecimal(true);
    if (this.pattern != null) {
      decimalFormat.applyPattern(this.pattern);
    }
    return decimalFormat;
  }

}
View Full Code Here

      // we never reach double digit grouping so return
      if(n < 100000) return removeTrailingZero(formatter.format(n));

      // switch to double digit grouping
      formatter.applyPattern("#,##");

      //divide by 1000, so that we get everything before the 3-group
      returnValue = formatter.format((int)(n / 1000)) + ",";

      // switch back to triple grouping + decimal
View Full Code Here

      //divide by 1000, so that we get everything before the 3-group
      returnValue = formatter.format((int)(n / 1000)) + ",";

      // switch back to triple grouping + decimal
      formatter.applyPattern("000.00");

      // remove value of number over 999 (so we just get the last
      // 5 digits)
      returnValue += formatter.format(n - (long)(n / 1000) * (long)1000);

 
View Full Code Here

      // we never reach double digit grouping so return
      if(n < 100000) return formatter.format(n);

      // switch to double digit grouping
      formatter.applyPattern("#,##");

      //divide by 1000, so that we get everything before the 3-group
      returnValue = formatter.format((int)(n / 1000)) + ",";

      // switch back to triple grouping + decimal
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.