Java Fraction Format formatDecimal(String format, double value)

Here you can find the source of formatDecimal(String format, double value)

Description

format Decimal

License

Open Source License

Declaration

public static String formatDecimal(String format, double value) 

Method Source Code

//package com.java2s;
/*//  w  w  w  .  j  a  va 2s  .c  om
 * PortUtil.cs
 * Copyright ? 2009-2011 kbinani
 *
 * This file is part of org.kbinani.
 *
 * org.kbinani is free software; you can redistribute it and/or
 * modify it under the terms of the BSD License.
 *
 * org.kbinani is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */

import java.text.DecimalFormat;

public class Main {
    public static String formatDecimal(String format, double value) {
        DecimalFormat df = new DecimalFormat(format);

        return df.format(value);
    }

    public static String formatDecimal(String format, long value) {
        DecimalFormat df = new DecimalFormat(format);

        return df.format(value);
    }
}

Related

  1. formatDecimal(double numToFormat)
  2. formatDecimal(double value)
  3. formatDecimal(double value, int maxFractionDigits1, int maxFractionDigits2)
  4. formatDecimal(double value, int precision)
  5. formatDecimal(double value, String mask)
  6. formatDecimals(double d, int mantissa)
  7. formatDecimals(double number)
  8. formatDecNumber(Double number, String pattern)
  9. formatDegToDms(double degrees, double min, double max)