code: private void setUserFieldValue(UDFAssignmentType udf, DataType dataType, Object value)
     {
        switch (dataType)
        {
           case DURATION:
           {
              udf.setTextValue(((Duration) value).toString());
              break;
           }
  
           case CURRENCY:
           {
              if (!(value instanceof Double))
              {
                 value = Double.valueOf(((Number) value).doubleValue());
              }
              udf.setCostValue((Double) value);
              break;
           }
  
           case BINARY:
           {
              udf.setTextValue("");
              break;
           }
  
           case STRING:
           {
              udf.setTextValue((String) value);
              break;
           }
  
           case DATE:
           {
              udf.setStartDateValue((Date) value);
              break;
           }
  
           case NUMERIC:
           {
              if (!(value instanceof Double))
              {
                 value = Double.valueOf(((Number) value).doubleValue());
              }
              udf.setDoubleValue((Double) value);
              break;
           }
  
           case BOOLEAN:
           {
              udf.setIntegerValue(BooleanHelper.getBoolean((Boolean) value) ? Integer.valueOf(1) : Integer.valueOf(0));
              break;
           }
  
           case INTEGER:
           case SHORT:
           {
              udf.setIntegerValue(NumberHelper.getInteger((Number) value));
              break;
           }
  
           default:
           {
              throw new RuntimeException("Unconvertible data type: " + dataType);
           }
        }
     }
docs: Sets the value of a UDF.
  
  @param udf user defined field
  @param dataType MPXJ data type
  @param value field value