from datetime import datetime


def formatDateTime(ts:datetime):
    """
        Formats the datetime according to D.2.1 of WMS Spec: ccyy-mm-ddThh:mm:ss.sssZ

        A time zone suffix is mandatory if the hours field appears in the time string. 
        All times should be expressed in Coordinated Universal Time (UTC), indicated 
        by the suffix Z (for "zulu"). When a local time applies, a numeric time zone 
        suffix as defined by ISO 8601:2004, 5.3.4.1 shall be used. The absence of any 
        suffix at all means local time in an undefined zone, which shall not be 
        used in the global network of map servers enabled by this International Standard.
    """
    return ts.isoformat(timespec='milliseconds').replace("+00:00","Z")