com.atlassian.jira.rest
Class Dates

java.lang.Object
  extended by com.atlassian.jira.rest.Dates

public class Dates
extends Object

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

Since:
v4.2

Nested Class Summary
static class Dates.DateAdapter
           
static class Dates.DateTimeAdapter
           
 
Field Summary
static String DATE_FORMAT
          The format used for dates in the REST plugin.
static String TIME_FORMAT
          The format used for times in the REST plugin.
 
Method Summary
static String asDateString(Date date)
          Converts the given Date object to a String.
static String asDateString(Timestamp timestamp)
          Converts the given Timestamp object to a 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 Date fromTimeString(String time)
          Converts the given date and time String to a Date object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATE_FORMAT

public static final String DATE_FORMAT
The format used for dates in the REST plugin.

See Also:
Constant Field Values

TIME_FORMAT

public static final String TIME_FORMAT
The format used for times in the REST plugin.

See Also:
Constant Field Values
Method Detail

asTimeString

public static String asTimeString(@Nullable
                                  Date date)
Converts the given Date object to a String. The returned string is in the format "yyyy-MM-dd\'T\'HH:mm:ss.SSSZ".

Parameters:
date - a Date
Returns:
a String representation of the date and time

asTimeString

public static String asTimeString(@Nullable
                                  Timestamp timestamp)
Converts the given Timestamp object to a String. The returned string is in the format "yyyy-MM-dd\'T\'HH:mm:ss.SSSZ".

Parameters:
timestamp - a Date
Returns:
a String representation of the timestamp and time

fromTimeString

public static Date fromTimeString(@Nullable
                                  String time)
                           throws IllegalArgumentException
Converts the given date and time String to a Date object. The time parameter is expected to be in the format "yyyy-MM-dd\'T\'HH:mm:ss.SSSZ".

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

asDateString

public static String asDateString(@Nullable
                                  Date date)
Converts the given Date 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

asDateString

public static String asDateString(@Nullable
                                  Timestamp timestamp)
Converts the given Timestamp object to a String. The returned string is in the format "yyyy-MM-dd".

Parameters:
timestamp - a Date
Returns:
a String representation of the timestamp

fromDateString

public static Date fromDateString(@Nullable
                                  String date)
                           throws IllegalArgumentException
Converts the given date String into a Date object. The date parameter is expected to be in the format "yyyy-MM-dd".

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


Copyright © 2002-2012 Atlassian. All Rights Reserved.