Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Does Android has its own DateFormat class if Java already has one?

Tags:

java

android

Same goes for other classes like SimpleDateFormat. Java has a java.text.SimpleDateFormat Android has android.icu.text.SimpleDateFormat

What could be the reason behind it? Does Android add its own set of features?

I'm concerned because recently I spent a lot of time wondering how people instantiated DateFormat class if it is an abstract class. Now I realised that android.text.format.DateFormat is a concrete class which can be instantiated as opposed to java.text.DateFormat which is an abstract class.

like image 991
Abhishek Kurve Avatar asked Feb 13 '26 17:02

Abhishek Kurve


1 Answers

CU4J is an open-source, widely used set of Java libraries providing Unicode and globalization support for software applications. Starting in Android 7.0 (API level 24), Android exposes a subset of the ICU4J APIs for app developers to use under the android.icu package. These APIs use localization data present on the device. As a result, you can reduce your APK footprint by not compiling the ICU4J libraries into your APK; instead, you can simply call out to them in the framework. (In this case, you may want to provide multiple versions of your APK, so users running versions of Android lower than Android 7.0 (API level 24) can download a version of the app that contains the ICU4J libraries.)

Android exposes a subset of the ICU4J APIs via the android.icu package, rather than com.ibm.icu. The Android framework may choose not to expose ICU4J APIs for various reasons; for example, Android does not expose some deprecated APIs or those that the ICU team have not yet declared as stable. As the ICU team deprecates APIs in the future, Android will also mark them as deprecated but will continue to include them.

(Source)

like image 127
Emmanuel Mtali Avatar answered Feb 15 '26 06:02

Emmanuel Mtali