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?
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
andandroid
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.
Either use java.math.BigDecimal
or android.icu.math.BigDecimal
, there will not be performance difference between both. Because these are basic class, Android BigDecimal
was re-created with reference of Java BigDecimal
.
If you ask difference between both, then
https://docs.oracle.com/javase/7/docs/api/java/math/BigDecimal.html https://developer.android.com/reference/java/math/BigDecimal
Android re-create classes to add some feature to existing classes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With