code: private void writeAvailability(Project.Resources.Resource xml, Resource mpx)
     {
        AvailabilityPeriods periods = m_factory.createProjectResourcesResourceAvailabilityPeriods();
        xml.setAvailabilityPeriods(periods);
        List<AvailabilityPeriod> list = periods.getAvailabilityPeriod();
        for (Availability availability : mpx.getAvailability())
        {
           AvailabilityPeriod period = m_factory.createProjectResourcesResourceAvailabilityPeriodsAvailabilityPeriod();
           list.add(period);
           DateRange range = availability.getRange();
  
           period.setAvailableFrom(range.getStart());
           period.setAvailableTo(range.getEnd());
           period.setAvailableUnits(DatatypeConverter.printUnits(availability.getUnits()));
        }
     }
docs: This method writes a resource's availability table.
  
  @param xml MSPDI resource
  @param mpx MPXJ resource