I have the latest AS 4.01 installed, and the latest dependency set up for Java 8 support with coreLibraryDesugaring (1.0.10), and proper compileOptions in my build.gradle file. The following code compiles and runs with no error on a device using API 23:

TemporalAccessor ta = null;
Instant i;
Date date = null;
try {
    int loc = 0;
    if ((loc = publishedDate.indexOf("+")) > 0) {
        // Offset time given
        publishedDate = adjustTimeFormat(publishedDate, loc);
        ta = DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(publishedDate);
        i = Instant.from(ta);
    } else if ((loc = publishedDate.indexOf("-")) > 0) {
        publishedDate = adjustTimeFormat(publishedDate, loc);
        ta = DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(publishedDate);
        i = Instant.from(ta);
    } else if (publishedDate.contains("Z")) {
        i = Instant.parse(publishedDate);
    } else {
        //
        ta = DateTimeFormatter.ISO_DATE.parse(publishedDate);
        i = Instant.from(ta);
    }
    date = Date.from(i);
} catch (Exception e) {
    ta = null;
}
if (ta == null) {
    date = new Date();
}
return date;

However, lint flags many of these lines as "requires API level 26 (current min is 21)"

I thought that with the desugaring in place, that it should allow this? Is this a lint bug?

0

There are 0 answers