Class DateUtils

java.lang.Object
com.atlassian.greenhopper.util.DateUtils

public class DateUtils extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.joda.time.DateTime
    epochMillisToDateTime(long timeSinceEpoch)
    Translates a field whose type is long into a DateTime.
    static org.joda.time.DateTime
    getTodayAt(org.joda.time.DateTimeZone timeZone)
    Gives today's local (server) time, at the given timezone (keeping the value)
    static boolean
    isInRange(org.joda.time.ReadableInstant date, org.joda.time.ReadableInstant startDate, org.joda.time.ReadableInstant endDate)
    Checks if the given date is in range, meaning equals or larger than the start date and less or equal to the end date.
    static boolean
    isToday(org.joda.time.DateMidnight date)
    Checks whether the given date is today.
    static org.joda.time.DateMidnight
    toDateMidnight(Long date, org.joda.time.DateTimeZone timeZone)
    Convert a Long instant (milliseconds) to DateMidnight.
    static org.joda.time.DateMidnight
    Convert a java.util.Date instance to DateMidnight.
    static org.joda.time.DateMidnight
    toDateMidnight(Date date, org.joda.time.DateMidnight defaultDate)
    Convert a java.util.Date instance to DateMidnight.
    static org.joda.time.DateMidnight
    toDateMidnight(Date date, org.joda.time.DateTimeZone timeZone)
    Convert a java.util.Date instance to DateMidnight.
    static org.joda.time.DateTime
    Converts a given date to a DateTime object
    static org.joda.time.DateTime
    toDateTime(Date date, org.joda.time.DateTimeZone timeZone)
    Converts a given date to a DateTime object, setting the timezone to the given value (while keeping the value)
    static long
    truncateMilliseconds(long milliseconds)
    Takes the long representing the milliseconds and truncates it to seconds.
    static long
    Takes the long representing the milliseconds and truncates it to seconds.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DateUtils

      public DateUtils()
  • Method Details

    • toDateMidnight

      public static org.joda.time.DateMidnight toDateMidnight(Date date, org.joda.time.DateTimeZone timeZone)
      Convert a java.util.Date instance to DateMidnight. DateMidnight has a fixed time component of 00:00, which is considered the first instant of the day, with the given timeZone.
      Returns:
      new DateMidnight instance of the same day, or null if the date parameter was null
    • toDateMidnight

      public static org.joda.time.DateMidnight toDateMidnight(Long date, org.joda.time.DateTimeZone timeZone)
      Convert a Long instant (milliseconds) to DateMidnight. DateMidnight has a fixed time component of 00:00, which is considered the first instant of the day, with the given timeZone.
      Returns:
      new DateMidnight instance of the same day, or null if the date parameter was null
    • toDateMidnight

      @Nullable public static org.joda.time.DateMidnight toDateMidnight(Date date)
      Convert a java.util.Date instance to DateMidnight. DateMidnight has a fixed time component of 00:00, which is considered the first instant of the day. It is timezone-aware.
      Returns:
      new DateMidnight instance of the same day, or null if the date parameter was null
    • toDateMidnight

      public static org.joda.time.DateMidnight toDateMidnight(@Nullable Date date, org.joda.time.DateMidnight defaultDate)
      Convert a java.util.Date instance to DateMidnight. DateMidnight has a fixed time component of 00:00, which is considered the first instant of the day. It is timezone-aware.
      Returns:
      new DateMidnight instance of the same day, or defaultDate if the date parameter was null
    • isInRange

      public static boolean isInRange(org.joda.time.ReadableInstant date, org.joda.time.ReadableInstant startDate, org.joda.time.ReadableInstant endDate)
      Checks if the given date is in range, meaning equals or larger than the start date and less or equal to the end date. If start date or end date is null, they're not taken into account, and any date is valid.
      Parameters:
      date - : the date to check
      startDate - : the lower boundary of the range
      endDate - : the upper boundary of the range
      Returns:
      true if the date is equal or between the lower and upper boundary
    • isToday

      public static boolean isToday(org.joda.time.DateMidnight date)
      Checks whether the given date is today.
    • toDateTime

      public static org.joda.time.DateTime toDateTime(Date date)
      Converts a given date to a DateTime object
    • toDateTime

      public static org.joda.time.DateTime toDateTime(Date date, org.joda.time.DateTimeZone timeZone)
      Converts a given date to a DateTime object, setting the timezone to the given value (while keeping the value)
    • getTodayAt

      public static org.joda.time.DateTime getTodayAt(org.joda.time.DateTimeZone timeZone)
      Gives today's local (server) time, at the given timezone (keeping the value)
    • truncateMilliseconds

      public static long truncateMilliseconds(long milliseconds)
      Takes the long representing the milliseconds and truncates it to seconds.
      Parameters:
      milliseconds - Time to truncate.
      Returns:
      Truncated milliseconds.
    • truncateMilliseconds

      public static long truncateMilliseconds(Date date)
      Takes the long representing the milliseconds and truncates it to seconds.
      Parameters:
      date - Time to truncate.
      Returns:
      Truncated milliseconds.
    • epochMillisToDateTime

      public static org.joda.time.DateTime epochMillisToDateTime(long timeSinceEpoch)
      Translates a field whose type is long into a DateTime. As of 8.0, Jira uses long epoch-offsets to represent dates in the index.
      Parameters:
      timeSinceEpoch - represents the number of milliseconds from the java epoch
      Returns:
      DateTime represented by the dateString