Java Fraction Format formatDecimals(double number)

Here you can find the source of formatDecimals(double number)

Description

format Decimals

License

Open Source License

Declaration

public static String formatDecimals(double number) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.DecimalFormat;

public class Main {
    public static String formatDecimals(long number) {
        return new DecimalFormat().format(number);
    }//w  w  w . j  a v  a  2 s  .  c o m

    public static String formatDecimals(long number, char separator) {
        return new DecimalFormat().format(number).replace(',', separator);
    }

    public static String formatDecimals(double number) {
        return new DecimalFormat().format(number);
    }

    public static String formatDecimals(double number, char separator) {
        return new DecimalFormat().format(number).replace(',', separator);
    }

    public static String replace(String source, String[] oldStrings, String[] newStrings) {
        if (oldStrings.length == newStrings.length) {
            for (int i = 0; i < newStrings.length; i++) {
                source = source.replace(oldStrings[i], newStrings[i]);
            }
        }
        return source;
    }
}

Related

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