How can I set custom Datetime format in XmlDateTime class
Question asked by Edgar Miuler - 4/1/2020 at 7:43 AM

I have some DateTime fields in XML therefore I am using XmlDateTime class.

It says that dateTime comprises [-]CCYY-MM-DDThh:mm:ss[.ff][[Z]|[[+|-]hh:mm]] 
However, I need to change that format (I need .fff, not .ff). How can I do that? 

1 Reply

Reply to Thread
Liquid Support Replied
Employee Post Marked As Answer

XmlDateTime will write out up to 9 fractional second digits, but does not write out trailing 0's as per the XML Schema specification:

Section Canonical representation:
- The fractional second string, if present, must not end in '0';

If you want a non-conforming date format then you can simply change the XSD to use an xs:string instead of an xs:dateTime and set whatever value you like. You could also specifying a Pattern facet on the xs:string to restrict valid values.

Reply to Thread