Java tutorial
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; import java.text.NumberFormat; import java.text.ParseException; import java.util.Locale; public class Main { public static String sGetDecimalStringAnyLocaleAs1Pt5LocalisedString(String value) { Locale theLocale = Locale.getDefault(); NumberFormat numberFormat = DecimalFormat.getInstance(theLocale); Number theNumber; try { theNumber = numberFormat.parse(value); } catch (ParseException e) { //value = sConvertDigits(value); String valueWithDot = value.replaceAll(",", "."); theNumber = Double.valueOf(valueWithDot); } // String.format uses the JVM's default locale. //String s = String.format(Locale.US, "%.2f", price); NumberFormat outputFormat = DecimalFormat.getInstance(theLocale); outputFormat.setMinimumIntegerDigits(1); outputFormat.setMinimumFractionDigits(5); outputFormat.setMaximumFractionDigits(5); String theStringResult = outputFormat.format(theNumber); //String theStringResult = String.format("%1.5f", theDoubleValue.doubleValue()); return theStringResult; } }