private static int [ ] getHijrahDateInfo ( long gregorianDays ) { int era , year , month , date , dayOfWeek , dayOfYear ; int cycleNumber , yearInCycle , dayOfCycle ; long epochDay = gregorianDays - HIJRAH_JAN_1_1_GREGORIAN_DAY ; if ( epochDay >= 0 ) { cycleNumber = getCycleNumber ( epochDay ) ; // 0 - 99. dayOfCycle = getDayOfCycle ( epochDay , cycleNumber ) ; // 0 - 10631. yearInCycle = getYearInCycle ( cycleNumber , dayOfCycle ) ; // 0 - 29. dayOfYear = getDayOfYear ( cycleNumber , dayOfCycle , yearInCycle ) ; // 0 - 354/355 year = cycleNumber * 30 + yearInCycle + 1 ; // 1-based year. month = getMonthOfYear ( dayOfYear , year ) ; // 0-based month-of-year date = getDayOfMonth ( dayOfYear , month , year ) ; // 0-based date ++ date ; // Convert from 0-based to 1-based era = HijrahEra . AH . getValue ( ) ; } else { cycleNumber = ( int ) epochDay / 10631 ; // 0 or negative number. dayOfCycle = ( int ) epochDay % 10631 ; // -10630 - 0. if ( dayOfCycle == 0 ) { dayOfCycle = - 10631 ; cycleNumber ++ ; } yearInCycle = getYearInCycle ( cycleNumber , dayOfCycle ) ; // 0 - 29. dayOfYear = getDayOfYear ( cycleNumber , dayOfCycle , yearInCycle ) ; year = cycleNumber * 30 - yearInCycle ; // negative number. year = 1 - year ; dayOfYear = ( isLeapYear ( year ) ? ( dayOfYear + 355 ) : ( dayOfYear + 354 ) ) ; month = getMonthOfYear ( dayOfYear , year ) ; date = getDayOfMonth ( dayOfYear , month , year ) ; ++ date ; // Convert from 0-based to 1-based era = HijrahEra . BEFORE_AH . getValue ( ) ; } // Hijrah day zero is a Friday dayOfWeek = ( int ) ( ( epochDay + 5 ) % 7 ) ; dayOfWeek += ( dayOfWeek <= 0 ) ? 7 : 0 ; int dateInfo [ ] = new int [ 6 ] ; dateInfo [ 0 ] = era ; dateInfo [ 1 ] = year ; dateInfo [ 2 ] = month + 1 ; // change to 1-based. dateInfo [ 3 ] = date ; dateInfo [ 4 ] = dayOfYear + 1 ; // change to 1-based. dateInfo [ 5 ] = dayOfWeek ; return dateInfo ; }
Returns the int array containing the following field from the julian day .