-8

What is at the moment best option for dealing with date in time in Android development, since Android studio doesn't yet support Java 8 (and new java.time package) (if I am correct)?

daneejela
  • 13,081
  • 7
  • 38
  • 50

2 Answers2

2

tl;dr

About java.time

The java.time framework is built into Java 8 and later. These classes supplant the troublesome old date-time classes such as java.util.Date, .Calendar, & java.text.SimpleDateFormat.

The Joda-Time project, now in maintenance mode, advises migration to java.time.

To learn more, see the Oracle Tutorial. And search Stack Overflow for many examples and explanations.

Java 6 & 7

Much of the java.time functionality is back-ported to Java 6 & 7 in ThreeTen-Backport.

Android: ThreeTenABP

That back-port is further adapted to Android in ThreeTenABP (see How to use…).

You should definitely avoid the troublesome confusing mess that is the legacy date-time classes.

Community
  • 1
  • 1
Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
1
  1. Support for Java 8 language features requires a new compiler called Jack. Jack is supported only on Android Studio 2.1 and higher. So if you want to use Java 8 language features, you need to use Android Studio 2.1 to build your app. Source: developer.android.com/guide/platform/j8-jack.html
  2. For date's and Timestamp you can see the links given below: using [java.util.Date]https://developer.android.com/reference/java/util/Date.html Or By using [java.text.SimpleDateFormat] https://developer.android.com/reference/java/text/SimpleDateFormat.html
m.arsrabon
  • 108
  • 1
  • 7