Java I18n 简明教程
Java Internationalization - Set Rounding Mode
Example
在此示例中,我们展示了舍入模式。
import java.math.RoundingMode;
import java.text.NumberFormat;
import java.util.Locale;
public class I18NTester {
public static void main(String[] args) {
Locale enLocale = new Locale("en", "US");
NumberFormat numberFormat = NumberFormat.getInstance(enLocale);
numberFormat.setMinimumFractionDigits(0);
numberFormat.setMaximumFractionDigits(0);
System.out.println(numberFormat.format(99.50));
numberFormat.setRoundingMode(RoundingMode.HALF_DOWN);
System.out.println(numberFormat.format(99.50));
}
}