code: private static Object getNativeValue(Object apiValue) {
      if (apiValue == null) {
        return null;
      } else if (apiValue instanceof DateTime) {
        return DateTimes.toDateTime((DateTime) apiValue);
      } else if (apiValue instanceof Date) {
        return DateTimes.toString((Date) apiValue);
      } else if (apiValue instanceof Set<?>) {
        Set<Object> nativeValues = new LinkedHashSet<Object>();
        for (Object entry : (Set<?>) apiValue) {
          validateSetValueEntryForSet(getNativeValue(entry), nativeValues);
          nativeValues.add(getNativeValue(entry));
        }
        return nativeValues;
      } else {
        return apiValue;
      }
    }
docs: Gets the underlying value of the api value object that's considered native to Java (i.e.
  DateTimeValue will return a Joda DateTime, not an API DateTime and DateValue will return a
  string in the form of "yyyy-MM-dd").
  
  @param apiValue the api value to convert
  @return the native value or {@code null} if the underlying value is null
  @throws IllegalArgumentException if apiValue cannot be converted