Here you can find the source of decimalFormatLabel(final long value, final long divider, final String unit)
Parameter | Description |
---|---|
value | the value to format |
divider | the divider to use |
unit | the unit label to append |
private static String decimalFormatLabel(final long value, final long divider, final String unit)
//package com.java2s; //License from project: Apache License import java.text.DecimalFormat; public class Main { /**/*from www . ja v a 2 s . c o m*/ * Formats a decimal value using a specified divider * * @param value the value to format * @param divider the divider to use * @param unit the unit label to append * @return the decimal formatted label */ private static String decimalFormatLabel(final long value, final long divider, final String unit) { final double result = divider > 1 ? (double) value / (double) divider : (double) value; return new DecimalFormat("#,##0.#").format(result) + " " + unit; } }