1

Trying to convert a LocalDate to Date using the following but getting this error:

Call requires API level 26 (current min is 21): java.util.Date#from

val finalDate = Date.from(finalLocalDate.atStartOfDay(ZoneId.systemDefault()).toInstant())

I cannot change the min SDK.

Just wondering that is the best way to do this?

ant2009
  • 27,094
  • 154
  • 411
  • 609
  • To handle Dates on apps the best thing you can do is switching to [ThreeTenABP](https://github.com/JakeWharton/ThreeTenABP) library, which works with API >= 15 – MatPag Jul 08 '21 at 10:35

1 Answers1

1

You need to use desugar_jdk_libs to use Java 8 Date APIs.
Docs and setup guide: https://developer.android.com/studio/write/java8-support

sdex
  • 3,169
  • 15
  • 28