public static Amount<Duration> getPeriodicConstraintOffset(Date date) {
   if (date == null) {
     return null;
   }
   Date midnight = MissionCalendarUtils.getMidnight(date);
   Amount<Duration> offset = DateUtils.subtract(date, midnight);
   return offset;
 }
 public static Date getPeriodicConstraintLatestDate(PeriodicTemporalConstraint constraint) {
   Amount<Duration> latest = constraint.getLatest();
   if (latest != null) {
     Date midnight = getPeriodicConstraintDate(constraint);
     if (midnight != null) {
       return DateUtils.add(midnight, latest);
     }
   }
   return null;
 }
 private Date getDefaultDate() {
   TemporalMember temporalMember = plan.getMember(TemporalMember.class);
   Date startDate = temporalMember.getStartTime();
   Amount<Duration> duration = temporalMember.getDuration();
   Date defaultDate = new Date();
   if (startDate != null && duration != null) {
     defaultDate = DateUtils.add(startDate, duration);
   }
   return defaultDate;
 }