Forums Register Login

Gregorian-Hijri Dates Converter JAVA

+Pie Number of slices to send: Send
+Pie Number of slices to send: Send
Did you have a question or are you just sharing your code ?
+Pie Number of slices to send: Send
Am just sharing the code
+Pie Number of slices to send: Send
Ok, thanks then.

I do have some comments about the code. It contains a lot of "magic" numbers: 365.25, 4716, 30.6001, 1524, 2299160, 1867216.25, 36524.25, 122.1, 10631, 1948084, 1948085, 8.01, 28.5001, 29.5001, ...

What do all those numbers mean? How do you know this code works correctly? For which range of dates does it work correctly?
+Pie Number of slices to send: Send
These numbers are used to calculate the Islamic Higri date, you can check if the date returned on the following site if its correct
http://www.islamicity.com/PrayerTimes/defaultHijriConv.asp
+Pie Number of slices to send: Send
365.25 in particular sounds suspicious - does this code handle leap years correctly in the long run?

Maybe you can provide a link to Wikipedia page or something like that where the topic (not necessarily the calculations) are explained.
+Pie Number of slices to send: Send
+Pie Number of slices to send: Send
Very useful .. thank you
+Pie Number of slices to send: Send
 

ghaith shamayleh wrote:These numbers are used to calculate the Islamic Higri date, you can check if the date returned on the following site if its correct
http://www.islamicity.com/PrayerTimes/defaultHijriConv.asp


Then make them constants - private static final fields of the right type (int / double) with a descriptive name.
+Pie Number of slices to send: Send
The duration of a year is not 365.25 days. According to this webpage that is 11min 14 seconds too long. anyway, using floating-point arithmetic is bound to cause imprecisions.
+Pie Number of slices to send: Send
 

Campbell Ritchie wrote:The duration of a year is not 365.25 days. According to this webpage that is 11min 14 seconds too long. anyway, using floating-point arithmetic is bound to cause imprecisions.


It's much more complicated than that.

According to Wikipedia, a Julian year is 365.25 days. I guess that the definition on the above website is the length of a Gregorian year (a year according to the usual Gregorial calendar). But there are also other ways to define a year: for example a sidereal year, which is the time it takes the Earth to make exactly one orbit around the Sun, is slightly different (365 days, 6 hours 9 minutes, 9.7676 seconds). And there are other definitions which are again slightly different.
+Pie Number of slices to send: Send
This code worked for me. But in my country its 25 rajab today and this code shows me 26 rajab. How can i change this please help me. Its so important for me. I have tried to change this by subtracting 1 but then it shows 0 as first day of month.Please help me
Thank you so much for your code.
+Pie Number of slices to send: Send
If you are using Java 8 then you do not need this code - the new date and time API in Java 8 already supports the Arabic calendar. You can simply do this:

+Pie Number of slices to send: Send
I am using java with android and It does not supports this
+Pie Number of slices to send: Send
There is a library named Time4A which can do what you need. It's an advanced date and time library specifically for Android.

See also this post: How to display name Hijri month as a String using Joda-Time?
+Pie Number of slices to send: Send
thanks its work in android studio
+Pie Number of slices to send: Send
SM: welcome to the Ranch
A berm makes a great wind break. And we all like to break wind once in a while. Like this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 20683 times.
Similar Threads
date question
Get the day
Calendar / Date arithmetic
Julian to Gregorian date conversion
I can't seem to get gredorian calender working right
Calculate date
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 04:56:25.