com.atlassian.jira.jql.util
Interface JqlDateSupport

All Known Implementing Classes:
JqlDateSupportImpl

public interface JqlDateSupport

Interface that helps with date parsing and validation in JQL.

Since:
v4.0

Method Summary
 Date convertToDate(Long dateLong)
          Converts the long to a date.
 Date convertToDate(String dateString)
          Try to parse the passed date string using the formats that JQL understands.
 DateRange convertToDateRange(Long dateLong)
          Converts the long to a date range where both values equal each other.
 DateRange convertToDateRangeWithImpliedPrecision(String dateString)
          Try to parse the passed in date string using the formats that JQL understands.
 String getDateString(Date date)
          Return a string representation of the passed date.
 String getIndexedValue(Date date)
          Converts a date into the index-friendly format.
 boolean validate(String dateString)
          Check to see if the passed string is a valid date according to JQL.
 

Method Detail

convertToDate

Date convertToDate(String dateString)
Try to parse the passed date string using the formats that JQL understands. It will consider the user's time zone when parsing the date string.

Parameters:
dateString - the string to parse. Cannot be null.
Returns:
the parsed date or null if it cant be parsed. You did call validate(String) right?
Throws:
IllegalArgumentException - if the passed dateString is null.

convertToDateRangeWithImpliedPrecision

DateRange convertToDateRangeWithImpliedPrecision(String dateString)
Try to parse the passed in date string using the formats that JQL understands. It will consider the user's time zone when parsing the date string.

It will eamine the single input string and use the implied precision to create the range

If you provide only a year/month/day it will have a precision of 24 hours, ie from the start of the day to the end of the day

If you supply year/month/day hour/minute, it will have a precision of 1 minute, ie from the start of the minute to the end of the minute.

Parameters:
dateString - the string to parse. Cannot be null.
Returns:
the parsed datetime as a range using the implied precision. Or null if the date cant be parsed. You did call validate(String) right?
Throws:
IllegalArgumentException - if the passed dateString is null.

convertToDate

Date convertToDate(Long dateLong)
Converts the long to a date.

Parameters:
dateLong - the long to give back a date for . Cannot be null.
Returns:
the parsed date.
Throws:
IllegalArgumentException - if the passed in Long is null

convertToDateRange

DateRange convertToDateRange(Long dateLong)
Converts the long to a date range where both values equal each other.

Parameters:
dateLong - the long to give back a date for . Cannot be null.
Returns:
the parsed date twice. Mostly for symmetry to calling code since JQL can have both long and string representations of values
Throws:
IllegalArgumentException - if the passed in Long is null

getIndexedValue

String getIndexedValue(Date date)
Converts a date into the index-friendly format.

Parameters:
date - the date
Returns:
a string representing the date, ready for comparison to indexed values.

validate

boolean validate(String dateString)
Check to see if the passed string is a valid date according to JQL.

Parameters:
dateString - the string to check cannot be null.
Returns:
true if the date is valid; false otherwise.
Throws:
IllegalArgumentException - if the passed dateString is blank or null

getDateString

String getDateString(Date date)
Return a string representation of the passed date. This method should just convert the date into its parseable String representation.

Parameters:
date - the date to convert. Cannot be null.
Returns:
return the passed date as a string.
Throws:
IllegalArgumentException - if the passed date is null.


Copyright © 2002-2012 Atlassian. All Rights Reserved.