Package java.text

Examples of java.text.DecimalFormat.formatToCharacterIterator()


    // check null argument
    boolean pass = false;
    try
      {
        f1.formatToCharacterIterator(null);
      }
    catch (NullPointerException e)
      {
        pass = true;
      }
View Full Code Here


    // check non-numeric argument
    pass = false;
    try
      {
        f1.formatToCharacterIterator("Not a number");
      }
    catch (IllegalArgumentException e)
      {
        pass = true;
      }
View Full Code Here

   
    DecimalFormat f2 = new DecimalFormat("0.##;-0.##");
   
    // result is "-1234.56"
    AttributedCharacterIterator chIter =
      f2.formatToCharacterIterator(Double.valueOf(-1234.56));
   
    Set _keys = chIter.getAllAttributeKeys();
   
    // It seems that we don't get always the same order in the results
    // but the values need to be the ones written later.
View Full Code Here

        .getInstance(Locale.US);
    decimalFormat.setRoundingMode(RoundingMode.UNNECESSARY);
    decimalFormat.setMaximumFractionDigits(0);
    try {
      // when rounding is needed, but RoundingMode is set to RoundingMode.UNNECESSARY, throw ArithmeticException
      decimalFormat.formatToCharacterIterator(new Double(1.5));
      fail("ArithmeticException expected");
    } catch (ArithmeticException e) {
      // expected
    }
  }
View Full Code Here

      // We need to get a character iterator for the zero part so we can use it if requested
      if (this.zeroFormat != null && zeroFormat.length()!=0) {//PM:7 oct. 2008:performance
        DecimalFormat temp = new DecimalFormat(this.zeroFormat);
        temp.setMultiplier(1);
        this.zeroFormatIterator = temp.formatToCharacterIterator(0);
        this.zeroFormatMaximumFractionalDigits = temp.getMaximumFractionDigits();
      }
      else {
        this.zeroFormatIterator = null;
        this.zeroFormatMaximumFractionalDigits = cNOT_SET;
View Full Code Here

      // We need to get a character iterator for the zero part so we can use it if requested
      if (this.zeroFormat != null && zeroFormat.length()!=0) {//PM:7 oct. 2008:performance
        DecimalFormat temp = new DecimalFormat(this.zeroFormat);
        temp.setMultiplier(1);
        this.zeroFormatIterator = temp.formatToCharacterIterator(0);
        this.zeroFormatMaximumFractionalDigits = temp.getMaximumFractionDigits();
      }
      else {
        this.zeroFormatIterator = null;
        this.zeroFormatMaximumFractionalDigits = cNOT_SET;
View Full Code Here

      // We need to get a character iterator for the zero part so we can use it if requested
      if (this.zeroFormat != null && zeroFormat.length()!=0) {//PM:7 oct. 2008:performance
        DecimalFormat temp = new DecimalFormat(this.zeroFormat);
        temp.setMultiplier(1);
        this.zeroFormatIterator = temp.formatToCharacterIterator(0);
        this.zeroFormatMaximumFractionalDigits = temp.getMaximumFractionDigits();
      }
      else {
        this.zeroFormatIterator = null;
        this.zeroFormatMaximumFractionalDigits = cNOT_SET;
View Full Code Here

      // We need to get a character iterator for the zero part so we can use it if requested
      if (this.zeroFormat != null && zeroFormat.length()!=0) {//PM:7 oct. 2008:performance
        DecimalFormat temp = new DecimalFormat(this.zeroFormat);
        temp.setMultiplier(1);
        this.zeroFormatIterator = temp.formatToCharacterIterator(0);
        this.zeroFormatMaximumFractionalDigits = temp.getMaximumFractionDigits();
      }
      else {
        this.zeroFormatIterator = null;
        this.zeroFormatMaximumFractionalDigits = cNOT_SET;
View Full Code Here

        .getInstance(Locale.US);
    decimalFormat.setRoundingMode(RoundingMode.UNNECESSARY);
    decimalFormat.setMaximumFractionDigits(0);
    try {
      // when rounding is needed, but RoundingMode is set to RoundingMode.UNNECESSARY, throw ArithmeticException
      decimalFormat.formatToCharacterIterator(new Double(1.5));
      fail("ArithmeticException expected");
    } catch (ArithmeticException e) {
      // expected
    }
  }
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.