Class Dates


  • public class Dates
    extends Object
    Utility class for formatting and parsing date and date/time objects in ISO8601 format.

    Unabashedly pinched from Jira

    Since:
    5.5
    • Field Detail

      • DATE_FORMAT

        @Deprecated
        public static final String DATE_FORMAT
        Deprecated.
        since 5.7. This date format will follow that provided by ISODateTimeFormat.date()
        The format used for dates in the REST plugin.
        See Also:
        Constant Field Values
      • TIME_FORMAT

        @Deprecated
        public static final String TIME_FORMAT
        Deprecated.
        since 5.7. This date time format will follow that provided by ISODateTimeFormat.dateTime()
        The format used for times in the REST plugin.
        See Also:
        Constant Field Values
    • Method Detail

      • asTimeString

        public static String asTimeString​(org.joda.time.DateTime date)
        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
      • asDateString

        public static String asDateString​(org.joda.time.DateTime date)
        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

        public static org.joda.time.DateTime fromDateString​(String date)
                                                     throws IllegalArgumentException
        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