Java – What is the Android equivalent of java.time.Duration?

What is the Android equivalent of java.time.Duration?… here is a solution to the problem.

What is the Android equivalent of java.time.Duration?

I need to use the class java.time.Duration to represent the time interval from submicroseconds to seconds. However, Android Studio does not provide this option.

I

guess I could use float and express everything as seconds, but that doesn’t seem very intuitive and makes sense.

These intervals have nothing to do with any real-world timeline, they are just spacers.

Solution

Rear port

See also back-port of much of java.time through Java 6 and 7, and it adaptation for Android.

Backward ports include org.threeten.bp.Duration Kind.


About java.time

placed in Java 8 and later within the java.time framework. These classes replace the troublesome old classes legacy datetime classes, eg java.util.Date , Calendar , & SimpleDateFormat .

Joda-Time project, now in maintenance mode, it is recommended to migrate to java.time class.

To learn more, see Oracle Tutorial. The specification is JSR 310

Where do I get the java.time class?

Related Problems and Solutions