From 5b00f0e0e36fec05b281e17e84a755ac97dea5ec Mon Sep 17 00:00:00 2001 From: Patryk Date: Wed, 28 Mar 2018 23:13:52 +0200 Subject: [PATCH] BAEL-1600 Internationalization in Java 8 (#3902) BigDecimal for currency formatting. --- .../NumbersCurrenciesFormattingUnitTest.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core-java-8/src/test/java/com/baeldung/internationalization/NumbersCurrenciesFormattingUnitTest.java b/core-java-8/src/test/java/com/baeldung/internationalization/NumbersCurrenciesFormattingUnitTest.java index 664c9d53ef..658ebb7e45 100644 --- a/core-java-8/src/test/java/com/baeldung/internationalization/NumbersCurrenciesFormattingUnitTest.java +++ b/core-java-8/src/test/java/com/baeldung/internationalization/NumbersCurrenciesFormattingUnitTest.java @@ -3,6 +3,7 @@ package com.baeldung.internationalization; import org.junit.Assert; import org.junit.Test; +import java.math.BigDecimal; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.text.NumberFormat; @@ -32,7 +33,7 @@ public class NumbersCurrenciesFormattingUnitTest { Locale usLocale = Locale.US; Locale plLocale = new Locale("pl", "PL"); Locale deLocale = Locale.GERMANY; - double number = 102_300.456d; + BigDecimal number = new BigDecimal(102_300.456d); NumberFormat usNumberFormat = NumberFormat.getCurrencyInstance(usLocale); NumberFormat plNumberFormat = NumberFormat.getCurrencyInstance(plLocale); @@ -46,7 +47,7 @@ public class NumbersCurrenciesFormattingUnitTest { @Test public void givenLocaleAndNumber_whenSpecificDecimalFormat_thenSpecificOutput() { Locale.setDefault(Locale.FRANCE); - double number = 102_300.456d; + BigDecimal number = new BigDecimal(102_300.456d); DecimalFormat zeroDecimalFormat = new DecimalFormat("000000000.0000"); DecimalFormat hashDecimalFormat = new DecimalFormat("###,###.#"); @@ -60,7 +61,7 @@ public class NumbersCurrenciesFormattingUnitTest { @Test public void givenLocaleAndNumber_whenSpecificDecimalFormatSymbols_thenSpecificOutput() { Locale.setDefault(Locale.FRANCE); - double number = 102_300.456d; + BigDecimal number = new BigDecimal(102_300.456d); DecimalFormatSymbols decimalFormatSymbols = DecimalFormatSymbols.getInstance(); decimalFormatSymbols.setGroupingSeparator('^');