// convert year to its 1-based month value
int m = month + 1;
// First, calculate time as a Gregorian date.
BaseCalendar cal = gcal;
BaseCalendar.Date cdate = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.NO_TIMEZONE);
cdate.setDate(y, m, day);
long time = cal.getTime(cdate); // normalize cdate
time += millis - rawOffset; // UTC time
// If the time value represents a time before the default
// Gregorian cutover, recalculate time using the Julian
// calendar system. For the Julian calendar system, the
// normalized year numbering is ..., -2 (BCE 2), -1 (BCE 1),
// 1, 2 ... which is different from the GregorianCalendar
// style year numbering (..., -1, 0 (BCE 1), 1, 2, ...).
if (time < GregorianCalendar.DEFAULT_GREGORIAN_CUTOVER) {
cal = (BaseCalendar) CalendarSystem.forName("julian");
cdate = (BaseCalendar.Date) cal.newCalendarDate(TimeZone.NO_TIMEZONE);
cdate.setNormalizedDate(y, m, day);
time = cal.getTime(cdate) + millis - rawOffset;
}
if ((cdate.getNormalizedYear() != y)
|| (cdate.getMonth() != m)
|| (cdate.getDayOfMonth() != day)