I am trying to use java.time.LocalDate in my android app, however if I try to import it, then any class from java.time gives a cannot resolve symbol error in Android studio 1.1
The only reason I could figure out for this is that it doesn’t support java 8. Is that really the case?
Android API level 26
Android API level 26 gained an implementation of java.time including your
For Android <26, alternatives include:
- ThreeTen-Backport is a back-port of much of the java.time functionality to Java 6 & 7.
- ThreeTenABP adapts ThreeTen-Backport to Android.
- Joda-Time is commonly used in Android projects. Joda-Time inspired the java.time package in Java 8, but they are not drop-in replacements. The Joda-Time team advises migration to java.time.
Where to obtain the java.time classes?
- Java SE 8, Java SE 9, Java SE 10, and later
- Part of the standard Java API with a bundled implementation.
- Java 9 adds some minor features and fixes.
- Java SE 6 and Java SE 7
- Much of the java.time functionality is back-ported to Java 6 & 7 in ThreeTen-Backport.
Yes, Android does not support Java-8. And about the new date/time-API contained in Java-8, you can look at this issue:
Currently there are no plans to introduce JSR-310 (java.time-package) in Google Android.
Finally date/time-API contained in Java 8 is added to Android API level 26 which was recently released.