0

Period.parse() requires API level 26. Is there any workaround to use it with minimum API level 17.

I am using

Period snoozeTime = Period.parse(rs.getString(rs.getColumnIndex("snoozeTime")));
Meno Hochschild
  • 42,708
  • 7
  • 104
  • 126
Shunan
  • 3,165
  • 6
  • 28
  • 48

2 Answers2

0

The main advantage of using ThreetenABP (a wrapper around the backport of JSR-310) might be to get the same feeling as if you use java.time.Period, but you have to change the import statement, namely org.threeten.bp.Period.

Duration parsers for Android are also available in Joda-Time-Android (called PeriodFormatter) or in my lib Time4A (for example pattern-based or as ISO-8601-parsing-methods in class Duration).

Note that the external APIs of Joda-Time and Time4J/A are superior to the parsing capabilities of JSR-310-class java.time.Period. Latter one can only understand some few ISO-8601-standard formats.

Meno Hochschild
  • 42,708
  • 7
  • 104
  • 126
0

Just use Java 8+ API desugaring support. Take a look: https://developer.android.com/studio/write/java8-support#library-desugaring

It's meant to provide the new java 8 features on Android with older apis

It's even recommended by ThreetenABP in its github page

tdmsoares
  • 533
  • 7
  • 24