How to use Umalqura calendar in java 8 with java.util.Date

we hear those days that java8 will include the Umalqura APi calendar , which controls the Hijri date.

Where can I find a sample that converts Date To Hijri?

Indeed, I find this code:

HijrahDate hdate = HijrahChronology.INSTANCE.date(LocalDate.of(2014, Month.JANUARY, 9));

However, I cannot install one INPUT (java.util.Date) instead of 3 INPUTS (YEAR, MONTH, DATE)

+4
source share
1 answer

You can convert from LocalDate- how you do it is up to you. For instance:

// Avoid using java.util.Date unless you really have to.
// Stick to java.time.* if possible
Date date = ...; 
Instant instant = Instant.ofEpochMilli(date.getTime());

// Pick the time zone you actually want here...
LocalDate localDate = instant.atZone(ZoneId.of("UTC")).toLocalDate();  

HijrahDate hdate = HijrahChronology.INSTANCE.date(instant);
+8
source

All Articles