public class

Dates

extends Object
java.lang.Object
   ↳ com.atlassian.jira.rest.Dates

Class Overview

Utility class for formatting and parsing date and date/time objects in ISO8601 format.

Summary

Nested Classes
class Dates.DateAdapter  
class Dates.DateTimeAdapter  
Constants
String DATE_FORMAT The format used for dates in the REST plugin.
String TIME_FORMAT The format used for times in the REST plugin.
Fields
public static final DateTimeFormatter ISO_DATE_TIME_PARSER Parser for rest times - this one - accepts Z as timezone.
public static final DateTimeFormatter ISO_DATE_TIME_PRINTER Printer for rest time entries - this one should print +0000 for UTC timezone.
Public Methods
static String asDateString(Timestamp timestamp)
Converts the given Timestamp object to a String.
static String asDateString(Date date)
Converts the given Date object to a String.
static String asISODateTimeString(DateTime dateTime)
Converts the given DateTime object to ISO String.
static String asTimeString(Date date)
Converts the given Date object to a String.
static String asTimeString(Timestamp timestamp)
Converts the given Timestamp object to a String.
static Date fromDateString(String date)
Converts the given date String into a Date object.
static DateTime fromISODateTimeString(String date)
static Date fromTimeString(String time)
Converts the given date and time String to a Date object.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String DATE_FORMAT

The format used for dates in the REST plugin.

Constant Value: "yyyy-MM-dd"

public static final String TIME_FORMAT

The format used for times in the REST plugin.

Constant Value: "yyyy-MM-dd'T'HH:mm:ss.SSSZ"

Fields

public static final DateTimeFormatter ISO_DATE_TIME_PARSER

Parser for rest times - this one - accepts Z as timezone.

public static final DateTimeFormatter ISO_DATE_TIME_PRINTER

Printer for rest time entries - this one should print +0000 for UTC timezone.

Public Methods

public static String asDateString (Timestamp timestamp)

Converts the given Timestamp object to a String. The returned string is in the format {@value #DATE_FORMAT}.

Parameters
timestamp a Date
Returns
  • a String representation of the timestamp

public static String asDateString (Date date)

Converts the given Date object to a String. The returned string is in the format {@value #DATE_FORMAT}.

Parameters
date a Date
Returns
  • a String representation of the date

public static String asISODateTimeString (DateTime dateTime)

Converts the given DateTime object to ISO String.

public static String asTimeString (Date date)

Converts the given Date object to a String. The returned string is in the format {@value #TIME_FORMAT}.

Parameters
date a Date
Returns
  • a String representation of the date and time

public static String asTimeString (Timestamp timestamp)

Converts the given Timestamp object to a String. The returned string is in the format {@value #TIME_FORMAT}.

Parameters
timestamp a Date
Returns
  • a String representation of the timestamp and time

public static Date fromDateString (String date)

Converts the given date String into a Date object. The date parameter is expected to be in the format {@value #DATE_FORMAT}.

Parameters
date a String containing a date
Returns
  • a Date
Throws
IllegalArgumentException if the input string is not in the expected format

public static DateTime fromISODateTimeString (String date)

public static Date fromTimeString (String time)

Converts the given date and time String to a Date object. The time parameter is expected to be in the format {@value #TIME_FORMAT}.

Parameters
time a String representation of a date and time
Returns
  • a Date
Throws
RuntimeException if there is an error parsing the date
IllegalArgumentException if the input string is not in the expected format