Joda api does not return correct islamic date

I am converting Gregorian dates to Islamic dates. I am setting my leap year model to Indian leap year but it is not working.

I am doing for cycle and Gregorian date which takes the current month and number is days and converts them to Islamic date. What I need

Here is my code

        for(int i=0;i<maxDay;i++)
        {
            eng.add(String.valueOf(i+1));
            DateTime dtISO=new DateTime(currentY,currentMonth+1,i+1,0,0);
            DateTimeZone asia= DateTimeZone.forID("Asia/Riyadh");

            DateTime dtIslamic = dtISO.withChronology(
                    IslamicChronology.getInstance(
                              asia, 
                              IslamicChronology.LEAP_YEAR_INDIAN));
            String islamicDateArr="";
            split=dtIslamic.toString().split("T");
            split=split[0].split("-");
            if(i==0 || Integer.parseInt(split[2])==1)
            {
                isl.add(String.valueOf(split[2]+" "+islamicMonths[Integer.parseInt(split[1])-1]));
                continue;
            }
            isl.add(String.valueOf(split[2]));
        }

      

+3


source to share


1 answer


Your code seems to be correct.

Since you told me that I have tried each of the four Joda-Time view models without success, I get the feeling that there might be a bug or just a missing feature, because among all the supported leap year patterns, there must be a couple that differ from each other by one day (and you see the difference in one day).

Other people have already presented bug issues. See here:

issue 163

issue 107

As you can see, it will be difficult for you to convince the project manager to solve your problem for you. Maybe he was right when he said that Joda-Time has no bug, but it just isn't complete.



Keep in mind that according to RH van Gent, the calculated Islamic calendar algorithm knows at least 8 instead of 4 variants as there are 4 intercalar schemes and (for each scheme) two variants depending on the exact start of the Islamic era (Thursday vs Friday epoch) ... Therefore, Joda-Time simply does not support all variations.

What are the alternatives to Joda-Time?

a) Java-8 and backport Threeten-BP (for Java-6 + 7) supports Saudi Arabia's Umalqura spreadsheet calendar (sight oriented). I'm not sure if this solves your problem (if not, then you can provide a handwritten file containing the table data pertaining to you - a lot of work). Please note that both libraries do not support algorithm based Islamic calendars.

b) Some people have written their own homemade workarounds. I found this hijri converter via google. Don't know if this works for you.

c) IBM offers the Hijri calendar in their ICU project. It offers different leap year models than Joda-Time. Perhaps it helps.

Side note. As you can see, the current Java support for Hijri calendars is not really satisfying. This is why I decided to create a new implementation in my own Time4J library . This is scheduled 2-3 months later in the fall of 2015.

+1


source







All Articles