Java BigDecimal vs Android BigDecimal

Mosius :

I've faced java.math.BigDecimal and android.icu.math.BigDecimal as I require to use BigDecimal in the project.

I've realized that the Android BigDecimal requires API level 24

What is the different between these two classes? I wonder if there is any performance optimization in Android implementation?

Markus Penguin :

android.icu.math.BigDecimal is part of the ICU library (International Components for Unicode). Since API 24 the Android framework exposes some of the ICU4J classes for you to use. The Android documentation on Unicode and I18N support states:

Some classes in the java and android packages have equivalents to those found in ICU4J. However, ICU4J often provides broader support for standards and languages.

Don't be confused by the above quote because ICU classes do reside in the android package. They were moved to android.icu from com.ibm.icu in order to avoid conflicts.

Regarding BigDecimal in particular: I found a discussion on the internet which concludes that BigDecimal was available in ICU before it was available in Java and is kept in the library for compatibility purposes.

Bottom line: use whatever implementation you like, but java.math.BigDecimal is less likely to be deprecated in the future.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=68481&siteId=1