com.atlassian.jira.jql.util
Class JqlDateSupportImpl

java.lang.Object
  extended by com.atlassian.jira.jql.util.JqlDateSupportImpl
All Implemented Interfaces:
JqlDateSupport

@ThreadSafe
public final class JqlDateSupportImpl
extends Object
implements JqlDateSupport

Default implementation for JqlDateSupport

Since:
v4.0

Constructor Summary
JqlDateSupportImpl(com.atlassian.core.util.Clock clock, TimeZoneManager timeZoneManager)
           
JqlDateSupportImpl(TimeZoneManager timeZoneManager)
           
 
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.
static String getDurationString(long duration)
           
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JqlDateSupportImpl

public JqlDateSupportImpl(com.atlassian.core.util.Clock clock,
                          TimeZoneManager timeZoneManager)

JqlDateSupportImpl

public JqlDateSupportImpl(TimeZoneManager timeZoneManager)
Method Detail

convertToDate

public Date convertToDate(String dateString)
Description copied from interface: JqlDateSupport
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.

Specified by:
convertToDate in interface JqlDateSupport
Parameters:
dateString - the string to parse. Cannot be null.
Returns:
the parsed date or null if it cant be parsed. You did call JqlDateSupport.validate(String) right?

convertToDateRangeWithImpliedPrecision

public DateRange convertToDateRangeWithImpliedPrecision(String dateString)
Description copied from interface: JqlDateSupport
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.

Specified by:
convertToDateRangeWithImpliedPrecision in interface JqlDateSupport
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 JqlDateSupport.validate(String) right?

convertToDate

public Date convertToDate(Long dateLong)
Description copied from interface: JqlDateSupport
Converts the long to a date.

Specified by:
convertToDate in interface JqlDateSupport
Parameters:
dateLong - the long to give back a date for . Cannot be null.
Returns:
the parsed date.

convertToDateRange

public DateRange convertToDateRange(Long dateLong)
Description copied from interface: JqlDateSupport
Converts the long to a date range where both values equal each other.

Specified by:
convertToDateRange in interface JqlDateSupport
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

getIndexedValue

public String getIndexedValue(Date date)
Description copied from interface: JqlDateSupport
Converts a date into the index-friendly format.

Specified by:
getIndexedValue in interface JqlDateSupport
Parameters:
date - the date
Returns:
a string representing the date, ready for comparison to indexed values.

validate

public boolean validate(String dateString)
Description copied from interface: JqlDateSupport
Check to see if the passed string is a valid date according to JQL.

Specified by:
validate in interface JqlDateSupport
Parameters:
dateString - the string to check cannot be null.
Returns:
true if the date is valid; false otherwise.

getDateString

public String getDateString(Date date)
Description copied from interface: JqlDateSupport
Return a string representation of the passed date. This method should just convert the date into its parseable String representation.

Specified by:
getDateString in interface JqlDateSupport
Parameters:
date - the date to convert. Cannot be null.
Returns:
return the passed date as a string.

getDurationString

public static String getDurationString(long duration)


Copyright © 2002-2012 Atlassian. All Rights Reserved.