Package java.text

Examples of java.text.NumberFormat.format()


    } else if (secs != 0) {
      NumberFormat format = NumberFormat.getInstance();
      format.setMinimumFractionDigits(2);
      format.setMaximumFractionDigits(2);

      String asString = format.format(secs + millis / 1000.0);

      return asString + " sec";
    } else {
      return millis + " millis";
    }
View Full Code Here


        if (cache_index < cached_number_formats.length) {
          cached_number_formats[cache_index] = nf;
        }
      }

      return nf.format(tValue);
    }
 
}
View Full Code Here

    else if (!sCurrency.equals(sCurr)) {
      oCurr = Currency.getInstance(sCurrency);
    }
    NumberFormat oFmtC = NumberFormat.getCurrencyInstance(oLoc);
    oFmtC.setCurrency(oCurr);
    return oFmtC.format(oDec.doubleValue());
  }

  // ----------------------------------------------------------

  /**
 
View Full Code Here

    else if (!sCurrency.equals(sCurr)) {
      oCurr = Currency.getInstance(sCurrency);
    }
    NumberFormat oFmtC = NumberFormat.getCurrencyInstance(oLoc);
    oFmtC.setCurrency(oCurr);
    return oFmtC.format(oDec.doubleValue());
  }

  // ----------------------------------------------------------
  /**
   * Format a BigDecimal as a String following the rules for an specific locale
View Full Code Here

    if (null==oLocale)
      oFmtC = NumberFormat.getCurrencyInstance(Locale.getDefault());
    else
      oFmtC = NumberFormat.getCurrencyInstance(oLocale);
    oFmtC.setCurrency(oCurr);
    return oFmtC.format(oDec.doubleValue());
  } // formatCurrency

  // ----------------------------------------------------------

  /**
 
View Full Code Here

      oLoc = new Locale(sLanguage);
    else
      oLoc = Locale.getDefault();
    NumberFormat oFmtC = NumberFormat.getCurrencyInstance(oLoc);
    oFmtC.setCurrency(currencyCode().currency());
    return oFmtC.format(doubleValue());
  } // format

  // ---------------------------------------------------------------------------

  public String toString () {
View Full Code Here

    integerFormat.setMaximumFractionDigits(0);
    if (abortedMeasureCount > 0) {
      buffer.append(lineSeparator);

      appendLabel(buffer, "Aborted " + mUnit, minLabelLength);
      buffer.append(integerFormat.format(abortedMeasureCount) + " " + mUnit + " (");

      // Ausgeben, wieviel % der Messungen fehl schlugen
      int total = abortedMeasureCount + measureCount;
      double errorPercent = (double) abortedMeasureCount / (double) total;
      buffer.append(RegainToolkit.toPercentString(errorPercent));
View Full Code Here

    }
    if (measureCount > 0) {
      buffer.append(lineSeparator);

      appendLabel(buffer, "Completed " + mUnit, minLabelLength);
      buffer.append(integerFormat.format(measureCount) + " " + mUnit + lineSeparator);

      appendLabel(buffer, "Total time", minLabelLength);
      buffer.append(RegainToolkit.toTimeString(totalTime) + lineSeparator);

      appendLabel(buffer, "Total data", minLabelLength);
View Full Code Here

      buffer.append(RegainToolkit.bytesToString(dataRatePerSec) + "/sec" + lineSeparator);

      appendLabel(buffer, "Output", minLabelLength);
      if (countsPerMinute > 10) {
        // No decimals when the count is high
        buffer.append(integerFormat.format(countsPerMinute) + " " + mUnit + "/min");
      } else {
        NumberFormat floatingFormat = NumberFormat.getInstance();
        floatingFormat.setMinimumFractionDigits(2);
        floatingFormat.setMaximumFractionDigits(2);
        buffer.append(floatingFormat.format(countsPerMinute) + " " + mUnit + "/min");
View Full Code Here

        buffer.append(integerFormat.format(countsPerMinute) + " " + mUnit + "/min");
      } else {
        NumberFormat floatingFormat = NumberFormat.getInstance();
        floatingFormat.setMinimumFractionDigits(2);
        floatingFormat.setMaximumFractionDigits(2);
        buffer.append(floatingFormat.format(countsPerMinute) + " " + mUnit + "/min");
      }
    }

    return buffer.toString();
  }
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.