Package org.jivesoftware.util
Class XMPPDateTimeFormat
java.lang.Object
org.jivesoftware.util.XMPPDateTimeFormat
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new thread-safe instance of this utility class -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Formats a Date object to String as defined in XEP-0082.static String
Formats a Date object to String as defined in XEP-0082.parseString
(String dateString) Tries to convert a given string to a Date object.
-
Field Details
-
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:
-
XMPP_DATETIME_FORMAT_WO_TIMEZONE
- See Also:
-
XMPP_DATETIME_FORMAT_WO_MILLIS_WO_TIMEZONE
- See Also:
-
XMPP_DATE_FORMAT
- See Also:
-
XMPP_TIME_FORMAT
- See Also:
-
XMPP_TIME_FORMAT_WO_MILLIS
- See Also:
-
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:
-
-
Constructor Details
-
XMPPDateTimeFormat
public XMPPDateTimeFormat()Create a new thread-safe instance of this utility class
-
-
Method Details
-
parseString
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
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
-
format
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:
instant
- the date to format- Returns:
- the formatted date
-