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 gained an implementation of java.time including your LocalDate
class.
For Android <26, alternatives include:
The java.time framework is built into Java 8 and later. These classes supplant the troublesome old legacy date-time classes such as java.util.Date
, Calendar
, & SimpleDateFormat
.
The Joda-Time project, now in maintenance mode, advises migration to the java.time classes.
To learn more, see the Oracle Tutorial. And search Stack Overflow for many examples and explanations. Specification is JSR 310.
You may exchange java.time objects directly with your database. Use a JDBC driver compliant with JDBC 4.2 or later. No need for strings, no need for java.sql.*
classes.
Where to obtain the java.time classes?
Yes, Android does not support Java-8. And about the new date/time-API contained in Java-8, you can look at this issue:
http://code.google.com/p/android/issues/detail?id=62192
Currently there are no plans to introduce JSR-310 (java.time-package) in Google Android.
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