Here you can find the source of adjustDoubleNumber(Double doubleNumber, int maxIntPart, int maxFloatPart)
public static Double adjustDoubleNumber(Double doubleNumber, int maxIntPart, int maxFloatPart)
//package com.java2s; //License from project: Open Source License import java.text.NumberFormat; import java.text.ParseException; import java.util.*; public class Main { public static Double adjustDoubleNumber(Double doubleNumber, int maxIntPart, int maxFloatPart) { NumberFormat numberFormat = NumberFormat.getInstance(Locale.getDefault()); numberFormat.setMaximumFractionDigits(maxFloatPart); numberFormat.setMaximumIntegerDigits(maxIntPart); numberFormat.setMinimumFractionDigits(maxFloatPart); try {// w w w. j a v a 2 s. c om doubleNumber = numberFormat.parse(numberFormat.format(doubleNumber)).doubleValue(); } catch (ParseException e) { new RuntimeException("The adjustDecimalNumber method haved an exception", e); } return doubleNumber; } }