com.atlassian.confluence.rest.serialization
Class Dates

java.lang.Object
  extended by com.atlassian.confluence.rest.serialization.Dates

public class Dates
extends java.lang.Object

Utility class for formatting and parsing date and date/time objects in ISO8601 format. Unabashedly pinched from JIRA

Since:
5.5

Field Summary
static java.lang.String DATE_FORMAT
          The format used for dates in the REST plugin.
static java.lang.String TIME_FORMAT
          The format used for times in the REST plugin.
 
Method Summary
static java.lang.String asDateString(org.joda.time.DateTime date)
          Converts the given DateTime object to a String.
static java.lang.String asTimeString(org.joda.time.DateTime date)
          Converts the given DateTime object to a String.
static org.joda.time.DateTime fromDateString(java.lang.String date)
          Converts the given date String into a DateTime object.
static org.joda.time.DateTime fromTimeString(java.lang.String time)
          Converts the given date and time String to a DateTime 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 java.lang.String DATE_FORMAT
The format used for dates in the REST plugin.

See Also:
Constant Field Values

TIME_FORMAT

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

See Also:
Constant Field Values
Method Detail

asTimeString

public static java.lang.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.SSSZ".

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

fromTimeString

public static org.joda.time.DateTime fromTimeString(java.lang.String time)
                                             throws java.lang.IllegalArgumentException
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.SSSZ".

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

asDateString

public static java.lang.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(java.lang.String date)
                                             throws java.lang.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:
java.lang.IllegalArgumentException - if the input string is not in the expected format


Copyright © 2003-2014 Atlassian. All Rights Reserved.