Android API level 26
Android API level 26 gained an implementation of java.time including your LocalDate
class.
Earlier Android
For Android <26, alternatives include:
- ThreeTen-Backport is a back-port of much of the java.time functionality to Java 6 & 7.
- 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.
About java.time
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?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…