Here you can find the source of formatFraction2(final Number value)
public static String formatFraction2(final Number value)
//package com.java2s; //License from project: Open Source License import java.text.NumberFormat; import java.util.Locale; public class Main { public static String formatFraction2(final Number value) { final Locale locale = Locale.getDefault(); final NumberFormat format = getNumberFraction2Format(locale); return format.format(value); }//from w w w. j av a 2 s . c o m public static NumberFormat getNumberFraction2Format(final Locale locale) { final NumberFormat format = NumberFormat.getNumberInstance(locale); format.setMaximumFractionDigits(2); format.setMinimumFractionDigits(2); return format; } }