Java Fraction Format formatDoubleString(double data, String pattern)

Here you can find the source of formatDoubleString(double data, String pattern)

Description

format Double String

License

Open Source License

Declaration

public static String formatDoubleString(double data, String pattern) 

Method Source Code


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

import java.text.DecimalFormat;

public class Main {

    public static String formatDoubleString(double data, String pattern) {
        DecimalFormat format = new DecimalFormat(pattern);

        if (data < 0) {
            return "0";
        }/*from  w w  w . j a v  a 2s.  c  o m*/

        if ((int) (data * 10) == (int) (data) * 10) {
            return (int) data + "";
        } else {
            return format.format(data);
        }
    }
}

Related

  1. formatDoubleAsPointsString(Double d)
  2. formatDoubleAsString(Double val)
  3. formatDoubleDecimal(float in)
  4. formatDoubleDecPoint2(Double value)
  5. formatDoubleList(List list)
  6. formatDoubleValue(String originalVal, Double valToProcess)
  7. formateNum(double num)
  8. formatFloat(double val1, double val2)
  9. formatFloat(float f, String format)