wiztools/xsd-gen

Detect dateTime correctly from ISO8601 formatted data

Closed this issue · 0 comments

Great library - very useful :-)

Would it be possible to add a feature where the data type is inferred from the contents? For example dateTime could be accurately guessed based on a content of ISO8601 formatted data (2000-01-01T12:34:56Z).

I'm thinking a few of these in TypeInferenceUtil:

private static final Pattern P_DATE_TIME = Pattern.compile("^([\\+-]?\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))([T\\s]((([01]\\d|2[0-3])((:?)[0-5]\\d)?|24\\:?00)([\\.,]\\d+(?!:))?)?(\\17[0-5]\\d([\\.,]\\d+)?)?([zZ]|([\\+-])([01]\\d|2[0-3]):?([0-5]\\d)?)?)?)?$");

This will correctly identify an ISO8601 format containing a valid date time.