MenoData / Time4J

Advanced date, time and interval library for Java with sun/moon-astronomy and calendars like Chinese, Coptic, Ethiopian, French Republican, Hebrew, Hijri, Historic Christian, Indian National, Japanese, Julian, Korean, Minguo, Persian, Thai, Vietnamese
GNU Lesser General Public License v2.1
424 stars 62 forks source link

TemporalType. INSTANT on Time4J #936

Closed mel4tonin4 closed 3 years ago

mel4tonin4 commented 3 years ago

Hello.

Why is TemporalType.INSTANT not available on Android?

What should I use instead?

Thanks.

MenoData commented 3 years ago

The conversion you want depends on java.time.Instant. This type is not available in old Android installations before level 26. Time4A is intentionally designed such that it even supports very old levels from 9 onwards. For more discussion see my answer to your previous question.

If you want to develop an Android app with the constraint to use only level 26+ then you can actually only do one of two ways:

a) You ignore java.time.Instant and simply use the class net.time4j.Moment directly (even including leap seconds). b) Or you convert a Moment to java.util.Date and then to Instant accepting some loss of precision (millisecond versus nanoseconds)

mel4tonin4 commented 3 years ago

See my comment to my other question, which takes into consideration both your answers. Thanks for your...time, Meno. Have a nice day!