Java Double to doubleToI18nString(double d)

Here you can find the source of doubleToI18nString(double d)

Description

double To In String

License

Open Source License

Declaration

public static String doubleToI18nString(double d) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2011 Boeing.//from   www.  j  a va2s  .co  m
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/

public class Main {
    public static String doubleToI18nString(double d) {
        return doubleToI18nString(d, false);
    }

    public static String doubleToI18nString(double d, boolean blankIfZero) {
        if (blankIfZero && d == 0) {
            return "";
        }
        // This enables java to use same string for all 0 cases instead of creating new one
        else if (d == 0) {
            return "0.00";
        } else {
            return String.format("%4.2f", d);
        }
    }
}

Related

  1. doubleToFloatArray(double[] doubles)
  2. doubleToFloatMatrix(double[][] matrix)
  3. doubleToFractionStr(final Double d)
  4. doubleToHashString(double value)
  5. doubleToHexString(double val)
  6. doubleToIndex(final double x)
  7. doubleToLex(double v)
  8. doubleToPercent(double value, int precision)
  9. doubleToRational(double number)