code: private void readTaskCustomFields(net.sf.mpxj.ganttproject.schema.Task gpTask, Task mpxjTask)
     {
        //
        // Populate custom field default values
        //
        Map<FieldType, Object> customFields = new HashMap<FieldType, Object>();
        for (Pair<FieldType, String> definition : m_taskPropertyDefinitions.values())
        {
           customFields.put(definition.getFirst(), definition.getSecond());
        }
  
        //
        // Update with custom field actual values
        //
        for (CustomTaskProperty property : gpTask.getCustomproperty())
        {
           Pair<FieldType, String> definition = m_taskPropertyDefinitions.get(property.getTaskpropertyId());
           if (definition != null)
           {
              //
              // Retrieve the value. If it is empty, use the default.
              //
              String value = property.getValueAttribute();
              if (value.isEmpty())
              {
                 value = null;
              }
  
              //
              // If we have a value,convert it to the correct type
              //
              if (value != null)
              {
                 Object result;
  
                 switch (definition.getFirst().getDataType())
                 {
                    case NUMERIC:
                    {
                       if (value.indexOf('.') == -1)
                       {
                          result = Integer.valueOf(value);
                       }
                       else
                       {
                          result = Double.valueOf(value);
                       }
                       break;
                    }
  
                    case DATE:
                    {
                       try
                       {
                          result = m_dateFormat.parse(value);
                       }
                       catch (ParseException ex)
                       {
                          result = null;
                       }
                       break;
                    }
  
                    case BOOLEAN:
                    {
                       result = Boolean.valueOf(value.equals("true"));
                       break;
                    }
  
                    default:
                    {
                       result = value;
                       break;
                    }
                 }
  
                 if (result != null)
                 {
                    customFields.put(definition.getFirst(), result);
                 }
              }
           }
        }
  
        for (Map.Entry<FieldType, Object> item : customFields.entrySet())
        {
           if (item.getValue() != null)
           {
              mpxjTask.set(item.getKey(), item.getValue());
           }
        }
     }
docs: Read custom fields for a GanttProject task.
  
  @param gpTask GanttProject task
  @param mpxjTask MPXJ Task instance