Here you can find the source of format(double input, String format)
Parameter | Description |
---|---|
input | The number to format. |
format | The formatting pattern, e.g. "0.00" (Number with 2 decimal digits). |
public static String format(double input, String format)
//package com.java2s; /*// www . j a v a2 s . c om * Copyright (c) 2014 mgamelabs * To see our full license terms, please visit https://github.com/mgamelabs/mengine/blob/master/LICENSE.md * All rights reserved. */ import java.text.DecimalFormat; public class Main { /** * Formats a number in a specified pattern. * * @param input The number to format. * @param format The formatting pattern, e.g. "0.00" (Number with 2 decimal digits). * @return The formatted number. */ public static String format(double input, String format) { DecimalFormat decimalFormat = new DecimalFormat(format); return decimalFormat.format(input); } }