Package com.ibm.icu.text

Examples of com.ibm.icu.text.NumberFormat.format()


     */
    public void testSetGroupingUsed() {
        NumberFormat nf = NumberFormat.getInstance();
        assertEquals("123,456,789", nf.format(123456789));
        nf.setGroupingUsed(false);
        assertEquals("123456789", nf.format(123456789));
    }

    /*
     * Test method for 'com.ibm.icu.x.text.NumberFormat.getMaximumIntegerDigits()'
     */
 
View Full Code Here


     * Test method for 'com.ibm.icu.x.text.NumberFormat.setMaximumIntegerDigits(int)'
     */
    public void testSetMaximumIntegerDigits() {
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMaximumIntegerDigits(4);
        assertEquals("3,456", nf.format(123456)); // high digits truncated
    }

    /*
     * Test method for 'com.ibm.icu.x.text.NumberFormat.getMinimumIntegerDigits()'
     */
 
View Full Code Here

     * Test method for 'com.ibm.icu.x.text.NumberFormat.setMinimumIntegerDigits(int)'
     */
    public void testSetMinimumIntegerDigits() {
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMinimumIntegerDigits(4);
        assertEquals("0,012", nf.format(12)); // pad out with zero, grouping still used
    }

    /*
     * Test method for 'com.ibm.icu.x.text.NumberFormat.getMaximumFractionDigits()'
     */
 
View Full Code Here

     * Test method for 'com.ibm.icu.x.text.NumberFormat.setMaximumFractionDigits(int)'
     */
    public void testSetMaximumFractionDigits() {
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMaximumFractionDigits(4);
        assertEquals("1.2346", nf.format(1.2345678)); // low digits rounded
    }

    /*
     * Test method for 'com.ibm.icu.x.text.NumberFormat.getMinimumFractionDigits()'
     */
 
View Full Code Here

     * Test method for 'com.ibm.icu.x.text.NumberFormat.setMinimumFractionDigits(int)'
     */
    public void testSetMinimumFractionDigits() {
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMinimumFractionDigits(4);
        assertEquals("1.2000", nf.format(1.2));
    }

    /*
     * Test method for 'com.ibm.icu.x.text.NumberFormat.toString()'
     */
 
View Full Code Here

    if (lno.fractionDigits != -1) {
      nf.setMinimumFractionDigits(lno.fractionDigits);
      nf.setMaximumFractionDigits(lno.fractionDigits);
    } else
      nf.setMaximumFractionDigits(1000);
    String ret = nf.format(n);
    do {
      if (lno.format != 'G' || ret.length() <= 15)
        break;
      /*
       * In this case, Lotus implicitly switches to scientific style.
View Full Code Here

       *  imitate this strange behaviour.
       */
      String tester = ret;
      if (lno.useGrouping) {
        nf.setGroupingUsed(false);
        tester = nf.format(n);
      }
      int minus = (tester.charAt(0) == '-') ? 1 : 0;
      int lh = tester.length();
      if (lh - minus <= 15)
        break;
View Full Code Here

          break;
      if (komma - minus <= 15)
        break;
      nf = NumberFormat.getScientificInstance(iLocale);
      nf.setGroupingUsed(lno.useGrouping);
      ret = nf.format(n);
    } while (false);
    if (lno.negativeAsParentheses && ret.charAt(0) == '-')
      ret = '(' + ret.substring(1) + ')';
    return ret;
  }
View Full Code Here

    public String formatNumber(int number, Locale locale) {
        if (locale == null) {
            locale = Aura.getLocalizationAdapter().getAuraLocale().getNumberLocale();
        }
        NumberFormat nf = NumberFormat.getNumberInstance(locale);
        return nf.format(number);
    }

    @Override
    public String formatNumber(long number, Locale locale) {
        if (locale == null) {
View Full Code Here

    public String formatNumber(long number, Locale locale) {
        if (locale == null) {
            locale = Aura.getLocalizationAdapter().getAuraLocale().getNumberLocale();
        }
        NumberFormat nf = NumberFormat.getNumberInstance(locale);
        return nf.format(number);
    }

    @Override
    public String formatNumber(double number, Locale locale) {
        if (locale == null) {
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.