Java Fraction Format formatWithOneDecimal(Float value)

Here you can find the source of formatWithOneDecimal(Float value)

Description

format With One Decimal

License

Apache License

Declaration

public static String formatWithOneDecimal(Float value) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.DecimalFormat;

public class Main {
    private static final DecimalFormat oneDecimalFormat = new DecimalFormat("##0.#");

    public static String formatWithOneDecimal(Float value) {
        if (value == null) {
            return "";
        }/*from   w w w.  j a  va 2s .c  om*/
        return oneDecimalFormat.format(value);
    }

    public static String formatWithOneDecimal(Double value) {
        if (value == null) {
            return "";
        }
        return oneDecimalFormat.format(value);
    }
}

Related

  1. formatToEightPlaces(double pValue)
  2. formatToString(Double v)
  3. formatTSYS(double tsys)
  4. formatTwoDecimalsToStr(float num)
  5. formatVersion(float versionNumber)