How to convert ReadableInstant (Joda time) to Java Date?

How to convert ReadableInstant (in Joda Time) to java.util.Date? ReadableInstant does not seem to have methods to convert to Date.

+4
source share
2 answers

Well, this is a little easier than I thought. ReadableInstant provides a getMillis () function that returns the time of an era as Long, so we can use it to convert to Date.

ReadableInstant instant;
Date date = new Date(instant.getMillis());
+2
source

You can also use this.

ReadableInstant instant;
Date date = DateTime.toDateTime(instant.getChronology()).toDate();

But the performance is not very good.

+2
source

Source: https://habr.com/ru/post/1546577/


All Articles