Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how could i return an Islamic calendar using java.util.Calendar?

Tags:

java

calendar

I knew that java.util.Calendar class method getInstance() returns a GregorianCalendar but how could i get an Islamic calendar?

like image 467
Mohammad Faisal Avatar asked Aug 06 '11 04:08

Mohammad Faisal


People also ask

What is Calendar getInstance () in Java?

The getInstance() method in Calendar class is used to get a calendar using the current time zone and locale of the system. Syntax: public static Calendar getInstance() Parameters: The method does not take any parameters. Return Value: The method returns the calendar.

How is Arabic Calendar calculated?

The Islamic calendar has 12 months with 29 or 30 days. If the Crescent Moon is visible shortly after sunset on the evening of day 29, the following day is the first day of the new month. If no sighting is made, a 30th day is added to the current month, which is then followed by the first day of the subsequent month.


2 Answers

There's not one built in the API.

You're going to have to subclass the Calendar class to do this or you could look at stuff that people have already written and if that will be suitable for you.

IBM has one implementation of the Hijri calendar.

There's also an approximate one provided by Joda-Time.

like image 52
Kal Avatar answered Sep 19 '22 13:09

Kal


I think the JDK does not ship with an implementation of the Islamic calendar. You'd have to use another library, such as Joda Time.

like image 38
Thilo Avatar answered Sep 19 '22 13:09

Thilo