Class MomentsAgoDateFormatter

java.lang.Object
com.biglybt.core.metasearch.utils.MomentsAgoDateFormatter

public class MomentsAgoDateFormatter extends Object
Improvement based on AZWEB-318.
Since:
3.2.1.0 6/19/2007
Version:
3.2.1.0 6/19/2007
  • Field Details

    • ID_YEAR

      private static final Integer ID_YEAR
    • ID_MONTH

      private static final Integer ID_MONTH
    • ID_WEEK_OF_YEAR

      private static final Integer ID_WEEK_OF_YEAR
    • ID_DAY

      private static final Integer ID_DAY
    • ID_HOUR_OF_DAY

      private static final Integer ID_HOUR_OF_DAY
    • ID_MINUTE

      private static final Integer ID_MINUTE
    • ID_SECOND

      private static final Integer ID_SECOND
    • MS_IN_YEAR

      private static final Long MS_IN_YEAR
    • MS_IN_MONTH

      private static final Long MS_IN_MONTH
    • MS_IN_WEEK

      private static final Long MS_IN_WEEK
    • MS_IN_DAY

      private static final Long MS_IN_DAY
    • MS_IN_HOUR

      private static final Long MS_IN_HOUR
    • MS_IN_MINUTE

      private static final Long MS_IN_MINUTE
    • MS_IN_SECOND

      private static final Long MS_IN_SECOND
    • AGO

      private static final String AGO
      See Also:
    • PLURAL

      private static final String PLURAL
      See Also:
    • CONVERSION_MAP

      private static final Map CONVERSION_MAP
    • UNIT_MAP

      private static final Map UNIT_MAP
  • Constructor Details

    • MomentsAgoDateFormatter

      public MomentsAgoDateFormatter()
  • Method Details

    • getMomentsAgoString

      public static String getMomentsAgoString(Date pastDate, DateFormat format)
      Returns "x ago on " by comparing the given pastDate with the current time. All formats are converted to GMT time. In the future the user might have their own locale, in which case we will display the time in their own locale (neat!)
      Parameters:
      pastDate - A date in the past
      format - The format for the pastDate
      Returns:
      "x ago on "
    • getMomentsAgoString

      public static String getMomentsAgoString(Date pastDate)
      Returns "x ago on " by comparing the given pastDate with the current time.
      Parameters:
      pastDate - A default locale date in the past
      Returns:
      "x ago"
    • handleUnit

      private static String handleUnit(Calendar then, Calendar now, Integer field)
      Checks to see if the unit we're comparing is less than the difference of the given "then" and "now" dates in milliseconds.
      Parameters:
      then - The date we're evaluating
      now - The current time
      field - The field which we're evaluating ("units")
      Returns:
      null if then is 0 "units" from now, otherwise a displayable string that will notify the user how long ago then was from now.