Package java.text

Examples of java.text.NumberFormat$NumberFormatGetter


   * @param maxFractionDigits Runde auf x Nachkommastellen
   * @return formatierte Darstellung der Zahl
   */
  public static String stringValue(Number number, Locale locale,
                                   boolean grouping, int maxFractionDigits) {
    NumberFormat nf = NumberFormat.getInstance(locale);
    nf.setGroupingUsed(grouping);
    nf.setMaximumFractionDigits(maxFractionDigits);
    return format(nf, number);
  }
View Full Code Here


   * @param fractionDigits Runde auf x Nachkommastellen
   * @return formatierte Währungsdarstellung der Zahl
   */
  public static String asCurrency(Number number, Locale locale,
                                  boolean grouping, int fractionDigits) {
    NumberFormat nf = NumberFormat.getCurrencyInstance(locale);
    nf.setGroupingUsed(grouping);
    nf.setMaximumFractionDigits(fractionDigits);
    return format(nf, number);
  }
View Full Code Here

   * @return die Textdarstellung als Zahl
   * @throws ParseException
   */
  public static Number asNumber(String text, Locale locale)
      throws ParseException {
    NumberFormat nf = NumberFormat.getInstance(locale);
    return nf.parse(text);
  }
View Full Code Here

   * @param text Textdarstellung der Zahl
   * @return die Textdarstellung als Zahl
   * @throws ParseException
   */
  public static Number asNumber(String text) throws ParseException {
    NumberFormat nf = NumberFormat.getInstance();
    return nf.parse(text);
  }
View Full Code Here

    if (bufWriter != null) {
      bufWriter.flush();
      bufWriter.close();
      bufWriter = null;
      final NumberFormat fmt = NumberFormat.getInstance();
      fmt.setGroupingUsed(true);
      final String strT = String.format("%3$s - File '%1$s' created, Size is : %2$s", fleFile.getAbsoluteFile(), fmt.format(fleFile.length()),
          conMethodName);
      message(strT);
      message(String.format("%3$s - file '%1$s' closed. '%2$d' lines written.", strFileName, lngNoOfLinesWritten, conMethodName));

    }
View Full Code Here

      FontMetrics metrics = getFontMetrics(getFont());
      int fontAscent = metrics.getAscent();
      float tickSize = 5 / rulerScale;
      float mainTickSize = (fontAscent + 6) / rulerScale;
      NumberFormat format = NumberFormat.getIntegerInstance();
     
      g2D.setColor(getForeground());
      float lineWidth = 0.5f / rulerScale;
      g2D.setStroke(new BasicStroke(lineWidth));
      if (this.orientation == SwingConstants.HORIZONTAL) {
View Full Code Here

          // objDFS.setDecimalSeparator('.');
          // objDFS.setGroupingSeparator(',');
          // System.out.println("DecimalSeparator = " + objDFS.getDecimalSeparator());
          // System.out.println("GroupingSeparator = " + objDFS.getGroupingSeparator());
          // numberF.setParseBigDecimal(true);
          final NumberFormat numberF = NumberFormat.getNumberInstance(Locale.GERMAN);
          numberF.setGroupingUsed(false);
          numberF.setParseIntegerOnly(false);
          numberF.setMaximumFractionDigits(5);
          numberF.setMinimumFractionDigits(0);
          final Number number = numberF.parse(strT);
          dblT = number instanceof Double ? number.doubleValue() : new Double(number.doubleValue());
        }
        catch (final ParseException e) {
          try {
            final NumberFormat numberF = NumberFormat.getNumberInstance(Locale.US);
            numberF.setGroupingUsed(false);
            numberF.setParseIntegerOnly(false);
            final Number number = numberF.parse(strT);
            dblT = number instanceof Double ? number.doubleValue() : new Double(number.doubleValue());
          }
          catch (final ParseException e1) {
            e1.printStackTrace();
            SignalError(conMethodName + ": could not convert '" + strT + "' to double");
View Full Code Here

        FormatHolder fmth = formatCache;  // atomic sampling
        if (fmth == null || !fmth.locale.equals(env.getLocale())) {
            synchronized(this) {
                fmth = formatCache;
                if (fmth == null || !fmth.locale.equals(env.getLocale())) {
                    NumberFormat fmt = NumberFormat.getNumberInstance(env.getLocale());
                    if (hasFormat) {
                        fmt.setMinimumFractionDigits(minFracDigits);
                        fmt.setMaximumFractionDigits(maxFracDigits);
                    } else {
                        fmt.setMinimumFractionDigits(0);
                        fmt.setMaximumFractionDigits(50);
                    }
                    fmt.setGroupingUsed(false);
                    formatCache = new FormatHolder(fmt, env.getLocale());
                    fmth = formatCache;
                }
            }
        }
View Full Code Here

        public Component getTableCellRendererComponent(JTable table,
             Object value, boolean isSelected, boolean hasFocus,
             int row, int column) {
          String currency = preferences.getCurrency();
          if (value != null && currency != null) {
            NumberFormat currencyFormat = DecimalFormat.getCurrencyInstance();
            currencyFormat.setCurrency(Currency.getInstance(currency));
            value = currencyFormat.format((BigDecimal)value);
          } else {
            value = "";
          }
          setHorizontalAlignment(JLabel.RIGHT);
          return super.getTableCellRendererComponent(
View Full Code Here

        public Component getTableCellRendererComponent(JTable table,
             Object value, boolean isSelected, boolean hasFocus,
             int row, int column) {
          BigDecimal valueAddedTaxPercentage = ((HomePieceOfFurniture)value).getValueAddedTaxPercentage();
          if (valueAddedTaxPercentage != null) {
            NumberFormat percentInstance = DecimalFormat.getPercentInstance();
            percentInstance.setMinimumFractionDigits(valueAddedTaxPercentage.scale() - 2);
            value = percentInstance.format(valueAddedTaxPercentage);
          } else {
            value = "";
          }
          setHorizontalAlignment(JLabel.RIGHT);
          return super.getTableCellRendererComponent(
View Full Code Here

TOP

Related Classes of java.text.NumberFormat$NumberFormatGetter

Copyright © 2018 www.massapicom. 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.