Class Dates
java.lang.Object
com.atlassian.confluence.rest.serialization.jackson2.Dates
Utility class for formatting and parsing date and date/time objects in ISO8601 format.
Unabashedly pinched from Jira
- Since:
- 8.9.0
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic String
asDateString
(org.joda.time.DateTime date) Converts the given DateTime object to a String.static String
asTimeString
(org.joda.time.DateTime date) Converts the given DateTime object to a String.static org.joda.time.DateTime
fromDateString
(String date) Converts the given date String into a DateTime object.static org.joda.time.DateTime
fromTimeString
(String time) Converts the given date and time String to a DateTime object.
-
Field Details
-
DATE_FORMAT
Deprecated.since 5.7. This date format will follow that provided byISODateTimeFormat.date()
The format used for dates in the REST plugin.- See Also:
-
TIME_FORMAT
Deprecated.since 5.7. This date time format will follow that provided byISODateTimeFormat.dateTime()
The format used for times in the REST plugin.- See Also:
-
-
Method Details
-
asTimeString
Converts the given DateTime object to a String. The returned string is in the format"yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ"
.- Parameters:
date
- a Date- Returns:
- a String representation of the date and time
-
fromTimeString
Converts the given date and time String to a DateTime object. The time parameter is expected to be in the format"yyyy-MM-dd\'T\'HH:mm:ss.SSSZZ"
.- Parameters:
time
- a String representation of a date and time- Returns:
- a Date
- Throws:
RuntimeException
- if there is an error parsing the dateIllegalArgumentException
- if the input string is not in the expected format
-
asDateString
Converts the given DateTime object to a String. The returned string is in the format"yyyy-MM-dd"
.- Parameters:
date
- a Date- Returns:
- a String representation of the date
-
fromDateString
Converts the given date String into a DateTime object. The date parameter is expected to be in the format"yyyy-MM-dd"
.- Parameters:
date
- a String containing a date- Returns:
- a DateTime
- Throws:
IllegalArgumentException
- if the input string is not in the expected format
-