Java Decimal Format decimalPointTwo(Float input)

Here you can find the source of decimalPointTwo(Float input)

Description

decimal Point Two

License

Open Source License

Declaration

public static String decimalPointTwo(Float input) 

Method Source Code

//package com.java2s;
/*/*from  w  ww  .  j a v  a  2s  .c  o m*/
 * CommonUtil.java 
 *
 * Copyright 2007 NHN Corp. All rights Reserved. 
 * NHN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

import java.math.RoundingMode;

import java.text.DecimalFormat;

public class Main {

    public static String decimalPointTwo(Float input) {
        if (input == null || input == 0) {
            return "0.0";
        }
        DecimalFormat df = new DecimalFormat("#.##");
        df.setRoundingMode(RoundingMode.FLOOR);
        return df.format(input);
    }

    public static String decimalPointTwo(Double input) {
        if (input == null || input == 0) {
            return "0.0";
        }
        DecimalFormat df = new DecimalFormat("#.##");
        df.setRoundingMode(RoundingMode.FLOOR);
        return df.format(input);
    }
}

Related

  1. decimalFormat(double value, int decimalCnt)
  2. decimalFormat(Object obj)
  3. decimalFormat(String pattern)
  4. decimalFormat(String pattern, double value)
  5. decimalFormatLabel(final long value, final long divider, final String unit)
  6. decimalString(double d, boolean forceDigits)
  7. encodeDouble(double d)
  8. getCorrectionValue(double basicValue, int digit)
  9. getDecimalFormat()