fields[MONTH] = day / 32; fields[DAY_OF_MONTH] = day - 31 * fields[MONTH];
fields[MONTH] = (int)day / 32; fields[DAY_OF_MONTH] = (int)day - 31 * fields[MONTH];
  private void calculateDay(int day, boolean gregorian)  {		// the epoch is a Thursday.		int weekday = (day + THURSDAY) % 7;		if (weekday <= 0)			weekday += 7;		fields[DAY_OF_WEEK] = weekday;		// get a first approximation of the year.  This may be one 		// year to big.    int year = 1970 + (gregorian		       ? ((day - 100) * 400) / (365 * 400 + 100 - 4 + 1)		       : ((day - 100) * 4) / (365 * 4 + 1));		if (day >= 0)			year++;		int firstDayOfYear = getLinearDay(year, 1, gregorian);		// Now look in which year day really lies.    if (day < firstDayOfYear)      {			year--;			firstDayOfYear = getLinearDay(year, 1, gregorian);		}		day -= firstDayOfYear - 1; // day of year,  one based.		fields[DAY_OF_YEAR] = day;    if (year <= 0)      {			fields[ERA] = BC;			fields[YEAR] = 1 - year;      }    else      {			fields[ERA] = AD;			fields[YEAR] = year;		}		int leapday = isLeapYear(year, gregorian) ? 1 : 0;    if (day <= 31 + 28 + leapday)      {			fields[MONTH] = day / 32; // 31->JANUARY, 32->FEBRUARY			fields[DAY_OF_MONTH] = day - 31 * fields[MONTH];      }    else      {			// A few more magic formulas			int scaledDay = (day - leapday) * 5 + 8;			fields[MONTH] = scaledDay / (31 + 30 + 31 + 30 + 31);			fields[DAY_OF_MONTH] = (scaledDay % (31 + 30 + 31 + 30 + 31)) / 5 + 1;		}	}