} if (earliest_demand == Long.MAX_VALUE) { firstDayOfDemand_ = 0; } else { firstDayOfDemand_ = convertTimeToDay(earliest_demand);
    private void initializeTime(Inventory inventory, long today) {	try {	    // Today is AlpTime, i.e. now            Enumeration role_sched = inventory.getRoleSchedule().getRoleScheduleElements();            long earliest_demand = Long.MAX_VALUE;            // StartTime_ is day 0 for this inventory. It is set to the            // earliest of 14 days before earliest demand or day of oldest            // inventory report.            // firstDayOfDemand is the day on which the IM receives its first request.            while (role_sched.hasMoreElements()) {                PlanElement pe = (PlanElement)role_sched.nextElement();                Task dueOut = pe.getTask();                try {                    long time;                    if (TaskUtils.isProjection(dueOut)) {                        time = TaskUtils.getStartTime(dueOut);                    } else {                        time = TaskUtils.getEndTime(dueOut);                    }                    earliest_demand = Math.min(time, earliest_demand);                } catch (RuntimeException re) {                    continue;   // No start time, probably                }            }            if (!isStartTimeSet) { // Need to set start time                long start_time = today;                InventoryReport oldest = getOldestInventoryReport();                start_time = Math.min(start_time, earliest_demand - 14 * TimeUtils.MSEC_PER_DAY);                if (oldest != null) {                    start_time = Math.min(start_time, oldest.theReportDate);                }                startDay_ = (int) (start_time / TimeUtils.MSEC_PER_DAY);                isStartTimeSet = true;            }            if (earliest_demand == Long.MAX_VALUE) {                firstDayOfDemand_ = 0;            } else {                firstDayOfDemand_ = convertTimeToDay(earliest_demand);            }            today_ = convertTimeToDay(today);        } catch (RuntimeException re) {          System.err.print(re + ": today=" + today + ", today_ = " + today_);          throw re;        }    }