2

I have just started trying to use the new Java Date Time API but when I went to import the classes like below,I get cannot resolve symbol.

import java.time.LocalDate; 

After a little bit of checking it I found that I need to enable java 8 (See below link).

https://developer.android.com/guide/platform/j8-jack.html

I assume this link is still relevant, info gets out of date very quickly. I am using a AS 2.1.3 and JDK 1.8 both installed yesterday (Not sure if that tells you anything).

I just want to make sure that if I go through the process of doing this, will it affect older model devices (In this case I will use Joda Time) or i1s the Java version totally irrelevant to the device.

Thanks

4
  • 2
    Yes, you'll only be able to use devices with Android N. Commented Sep 14, 2016 at 1:20
  • @chrylis Awesome thanks for that. I will stick with Joda time then. Appreciate the help Commented Sep 14, 2016 at 1:22
  • @chrylis Are you sure? That link in the question lists some of the features work on sdk 23 and lower. I think the Jack toolchain allows Java 8 to be used in any version Commented Sep 14, 2016 at 3:27
  • 2
    @cricket_007 He asked about the DateTime API specifically, which is a library issue, not a bytecode issue. Commented Sep 14, 2016 at 3:36

1 Answer 1

3

Back-ports

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

ThreeTenABP

Further adapted to Android in the ThreeTenABP project. See: How to use ThreeTenABP in Android project.


The Joda-Time project is in maintenance mode. The team advises migration to the java.time classes.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.