4

we hear those days that java8 will includes Umalqura calendar APi which manages Hijri Date .

Where to find a sample that convert Date To Hijri ?

Indeed , i find this code :

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

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

4

1 回答 1

9

你可以从一个转换LocalDate- 你如何得到这取决于你。例如:

// 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);
于 2014-11-25T06:49:26.680 回答