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

      • XMPP_DATETIME_FORMAT

        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
      • XMPP_DATETIME_FORMAT_WO_MILLIS_WO_TIMEZONE

        public static final String XMPP_DATETIME_FORMAT_WO_MILLIS_WO_TIMEZONE
        See Also:
        Constant Field Values
      • XMPP_DELAY_DATETIME_FORMAT

        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.
        Parameters:
        dateString - the String that should be parsed
        Returns:
        the parsed date or null if the String could not be parsed
        Throws:
        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
        Parameters:
        date - the date to format
        Returns:
        the formatted date