Class JqlDateSupportImpl

java.lang.Object
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 Details

    • JqlDateSupportImpl

      public JqlDateSupportImpl(Clock clock, TimeZoneManager timeZoneManager)
    • JqlDateSupportImpl

      public JqlDateSupportImpl(TimeZoneManager timeZoneManager)
  • Method Details

    • 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?
    • convertToDate

      public Date convertToDate(String dateString, TimeZone timeZone)
      Description copied from interface: JqlDateSupport
      Try to parse the passed date string using the formats that JQL understands. It will use the passed time zone when parsing the date string.
      Specified by:
      convertToDate in interface JqlDateSupport
      Parameters:
      dateString - the string to parse. Cannot be null.
      timeZone - time zone to use when parsing.
      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
    • 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. The user's time zone will be used when formatting the date string.
      Specified by:
      getDateString in interface JqlDateSupport
      Parameters:
      date - the date to convert. Cannot be null.
      Returns:
      return the passed date as a string.
    • getDateString

      public String getDateString(Date date, TimeZone timeZone)
      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. The passed time zone will be used when formatting the date string.
      Specified by:
      getDateString in interface JqlDateSupport
      Parameters:
      date - the date to convert. Cannot be null.
      timeZone - time zone to use. Cannot be null.
      Returns:
      return the passed date as a string.
    • isDuration

      public boolean isDuration(String dateString)
      Description copied from interface: JqlDateSupport
      Returns a boolean value indicating whether the passed date string representation has duration format, e.g., 4d 1h, -1w.
      Specified by:
      isDuration in interface JqlDateSupport
      Parameters:
      dateString - the string to parse.
      Returns:
      true if the passed date string has duration format, false otherwise.
    • getDurationString

      public static String getDurationString(long duration)