Examples of NumberFormat


Examples of java.text.NumberFormat

    // Get it's eng format. Get it as string without trailing 0's
    final double outputValue = rounded / Math.pow(10, Math.floor(log10 / 3.0) * 3);
    final int outputValueDecimalPlaces = Math.max (1, computeLog10(outputValue));
   
    final Locale locale = context.getLocalizationContext().getLocale();
    final NumberFormat decimalFormat = createDecimalFormat(fixedSize, outputValueDecimalPlaces, precision, locale);
    final String result = decimalFormat.format(outputValue) + SUFFIXES[index];
    return new TypeValuePair(TextType.TYPE, result);
  }
View Full Code Here

Examples of java.text.NumberFormat

  private NumberFormat createDecimalFormat(final boolean fixedSize,
                                           final int decimalPlaces,
                                           final int precision,
                                           final Locale locale)
  {
    final NumberFormat format = NumberFormat.getNumberInstance(locale);
    format.setGroupingUsed(false);
    if (fixedSize)
    {
      format.setMinimumFractionDigits(Math.max(0, precision - decimalPlaces - 1));
    }
    else
    {
      format.setMinimumFractionDigits(precision);
    }
    return format;
  }
View Full Code Here

Examples of java.text.NumberFormat

    public void setCurrency(Currency currency) {
        this.currency = currency;
    }

    @Override public String getCaption(Locale locale) {
        NumberFormat formatter = locale == null ? NumberFormat.getCurrencyInstance() : NumberFormat.getCurrencyInstance(locale);
        formatter.setCurrency(currency.getCurrency());
        return formatter.format(amount);
    }
View Full Code Here

Examples of java.text.NumberFormat

     */

    public String getCurveInformation(double xmin, double xmax){
        try{
            computeStatistics(xmin, xmax);
            NumberFormat nf = NumberFormat.getInstance();
            nf.setMaximumFractionDigits(STATISTIC_ACCURACY);   

            String curveStat ="";

            if (SHOW_X_MIN){
                curveStat += "X min = " + nf.format(localRangeMinPoint.x+ "; ";
            }
            if (SHOW_X_MAX){
                curveStat += "X max = " + nf.format(localRangeMaxPoint.x+ "; ";
            }
            if (SHOW_Y_MIN){
                curveStat += "Y min = " + nf.format(localRangeMinPoint.y+ "; ";
            }
            if (SHOW_Y_MAX){
                curveStat += "Y max = " + nf.format(localRangeMaxPoint.y+ "; ";
            }
            if (SHOW_POINT_NUMBER){
                curveStat += "Nb pts = " + getLocalNbPoints()  + "; ";
            }
            if (SHOW_MEAN){
                curveStat += "Mean = " + nf.format(getLocalRangeMean()) + "; ";
            }
            if (SHOW_DEVIATION){
                curveStat += "Deviation = " + nf.format(getLocalDeviationValue()) + "; ";
            }
            if (SHOW_INTEGRAL){
                curveStat += "Integral = " + nf.format(getLocalIntegralValue())  + "; ";
            }

            return curveStat;

        }catch (DataException e){
View Full Code Here

Examples of java.text.NumberFormat

   *
   * @param value Der Wert. (Zwischen 0 und 1)
   * @return Der Wert in Prozent.
   */
  public static String toPercentString(double value) {
    NumberFormat format = NumberFormat.getPercentInstance();
    format.setMinimumFractionDigits(2);
    format.setMaximumFractionDigits(2);
    return format.format(value);
  }
View Full Code Here

Examples of java.text.NumberFormat

      unit = "kB";
    } else {
      return bytes + " Byte";
    }

    NumberFormat format = NumberFormat.getInstance(locale);
    format.setMinimumFractionDigits(fractionDigits);
    format.setMaximumFractionDigits(fractionDigits);

    String asString = format.format((double) bytes / (double) factor);

    return asString + " " + unit;
  }
View Full Code Here

Examples of java.text.NumberFormat

              + ((secs > 9) ? "" : "0") + secs + " h";
    } else if (mins != 0) {
      return mins + ":"
              + ((secs > 9) ? "" : "0") + secs + " min";
    } 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

Examples of java.text.NumberFormat

      }

      int cache_index = (precision << 2) + ((bTruncateZeros ? 1 : 0) << 1)
          + (bRound ? 1 : 0);

      NumberFormat nf = null;

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

      if (nf == null) {
        nf = NumberFormat.getNumberInstance();
        nf.setGroupingUsed(false); // no commas
        if (!bTruncateZeros) {
          nf.setMinimumFractionDigits(precision);
        }
        if (bRound) {
          nf.setMaximumFractionDigits(precision);
        }

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

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

Examples of java.text.NumberFormat

      oCurr = Currency.getInstance(oLoc);
    }
    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

Examples of java.text.NumberFormat

      oCurr = Currency.getInstance(oLoc);
    }
    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
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.