private int[] createEpochMonths(int epochDay,int minYear,int maxYear,Map<Integer,int[]> years){
  int numMonths=(maxYear - minYear + 1) * 12 + 1;
  int epochMonth=0;
  int[] epochMonths=new int[numMonths];
  minMonthLength=Integer.MAX_VALUE;
  maxMonthLength=Integer.MIN_VALUE;
  for (int year=minYear; year <= maxYear; year++) {
    int[] months=years.get(year);
    for (int month=0; month < 12; month++) {
      int length=months[month];
      epochMonths[epochMonth++]=epochDay;
      if (length < 29 || length > 32) {
        throw new IllegalArgumentException("Invalid month length in year: " + minYear);
      }
      epochDay+=length;
      minMonthLength=Math.min(minMonthLength,length);
      maxMonthLength=Math.max(maxMonthLength,length);
    }
  }
  epochMonths[epochMonth++]=epochDay;
  if (epochMonth != epochMonths.length) {
    throw new IllegalStateException("Did not fill epochMonths exactly: ndx = " + epochMonth + " should be "+ epochMonths.length);
  }
  return epochMonths;
}

private int [ ] createEpochMonths ( int epochDay , int minYear , int maxYear , Map < Integer , int [ ] > years ) { int numMonths = ( maxYear - minYear + 1 ) * 12 + 1 ; int epochMonth = 0 ; int [ ] epochMonths = new int [ numMonths ] ; minMonthLength = Integer . MAX_VALUE ; maxMonthLength = Integer . MIN_VALUE ; for ( int year = minYear ; year <= maxYear ; year ++ ) { int [ ] months = years . get ( year ) ; for ( int month = 0 ; month < 12 ; month ++ ) { int length = months [ month ] ; epochMonths [ epochMonth ++ ] = epochDay ; if ( length < 29 || length > 32 ) { throw new IllegalArgumentException ( "Invalid month length in year: " + minYear ) ; } epochDay += length ; minMonthLength = Math . min ( minMonthLength , length ) ; maxMonthLength = Math . max ( maxMonthLength , length ) ; } } epochMonths [ epochMonth ++ ] = epochDay ; if ( epochMonth != epochMonths . length ) { throw new IllegalStateException ( "Did not fill epochMonths exactly: ndx = " + epochMonth + " should be " + epochMonths . length ) ; } return epochMonths ; }
converts the map of year to month lengths ranging from minyear to maxyear into a linear contiguous array of epochdays . the index is the hijrahmonth computed from year and month and offset by minyear . the value of each entry is the epochday corresponding to the first day of the month .
