Class XMPPDateTimeFormat

  • public class XMPPDateTimeFormat
    extends Object
    Utility class for date/time format conversions as specified in XEP-0082 and XEP-0090 and For Date -> String converstion FastDateFormat is used
    • Field Detail


        public static final String XMPP_DATETIME_FORMAT
        Date/time format for use by SimpleDateFormat. The format conforms to XEP-0082, which defines a unified date/time format for XMPP.
        See Also:
        Constant Field Values

        public static final String XMPP_DATETIME_FORMAT_WO_MILLIS_WO_TIMEZONE
        See Also:
        Constant Field Values

        public static final String XMPP_DELAY_DATETIME_FORMAT
        Date/time format for use by SimpleDateFormat. The format conforms to the format defined in XEP-0091, a specialized date format for historical XMPP usage.
        See Also:
        Constant Field Values
    • Constructor Detail

      • XMPPDateTimeFormat

        public XMPPDateTimeFormat()
        Create a new thread-safe instance of this utility class
    • Method Detail

      • parseString

        public Date parseString​(String dateString)
                         throws ParseException
        Tries to convert a given string to a Date object. This method supports the format types defined by XEP-0082 and the format defined in legacy protocols XEP-0082: CCYY-MM-DDThh:mm:ss[.sss]TZD legacy: CCYYMMDDThh:mm:ss This method either returns a Date instance as result or it will return null or throw a ParseException in case the String couldn't be parsed.
        dateString - the String that should be parsed
        the parsed date or null if the String could not be parsed
        ParseException - if the date could not be parsed
      • format

        public static String format​(Date date)
        Formats a Date object to String as defined in XEP-0082. The resulting String will have the timezone set to UTC ('Z') and includes milliseconds: CCYY-MM-DDThh:mm:ss.sssZ
        date - the date to format
        the formatted date