Class MomentsAgoDateFormatter
- java.lang.Object
-
- com.biglybt.core.metasearch.utils.MomentsAgoDateFormatter
-
public class MomentsAgoDateFormatter extends java.lang.Object
Improvement based on AZWEB-318.- Since:
- 3.2.1.0 6/19/2007
- Version:
- 3.2.1.0 6/19/2007
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
AGO
private static java.util.Map
CONVERSION_MAP
private static java.lang.Integer
ID_DAY
private static java.lang.Integer
ID_HOUR_OF_DAY
private static java.lang.Integer
ID_MINUTE
private static java.lang.Integer
ID_MONTH
private static java.lang.Integer
ID_SECOND
private static java.lang.Integer
ID_WEEK_OF_YEAR
private static java.lang.Integer
ID_YEAR
private static java.lang.Long
MS_IN_DAY
private static java.lang.Long
MS_IN_HOUR
private static java.lang.Long
MS_IN_MINUTE
private static java.lang.Long
MS_IN_MONTH
private static java.lang.Long
MS_IN_SECOND
private static java.lang.Long
MS_IN_WEEK
private static java.lang.Long
MS_IN_YEAR
private static java.lang.String
PLURAL
private static java.util.Map
UNIT_MAP
-
Constructor Summary
Constructors Constructor Description MomentsAgoDateFormatter()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
getMomentsAgoString(java.util.Date pastDate)
Returns "xago on " by comparing the given pastDate with the current time. static java.lang.String
getMomentsAgoString(java.util.Date pastDate, java.text.DateFormat format)
Returns "xago on " by comparing the given pastDate with the current time. private static java.lang.String
handleUnit(java.util.Calendar then, java.util.Calendar now, java.lang.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.
-
-
-
Field Detail
-
ID_YEAR
private static final java.lang.Integer ID_YEAR
-
ID_MONTH
private static final java.lang.Integer ID_MONTH
-
ID_WEEK_OF_YEAR
private static final java.lang.Integer ID_WEEK_OF_YEAR
-
ID_DAY
private static final java.lang.Integer ID_DAY
-
ID_HOUR_OF_DAY
private static final java.lang.Integer ID_HOUR_OF_DAY
-
ID_MINUTE
private static final java.lang.Integer ID_MINUTE
-
ID_SECOND
private static final java.lang.Integer ID_SECOND
-
MS_IN_YEAR
private static final java.lang.Long MS_IN_YEAR
-
MS_IN_MONTH
private static final java.lang.Long MS_IN_MONTH
-
MS_IN_WEEK
private static final java.lang.Long MS_IN_WEEK
-
MS_IN_DAY
private static final java.lang.Long MS_IN_DAY
-
MS_IN_HOUR
private static final java.lang.Long MS_IN_HOUR
-
MS_IN_MINUTE
private static final java.lang.Long MS_IN_MINUTE
-
MS_IN_SECOND
private static final java.lang.Long MS_IN_SECOND
-
AGO
private static final java.lang.String AGO
- See Also:
- Constant Field Values
-
PLURAL
private static final java.lang.String PLURAL
- See Also:
- Constant Field Values
-
CONVERSION_MAP
private static final java.util.Map CONVERSION_MAP
-
UNIT_MAP
private static final java.util.Map UNIT_MAP
-
-
Method Detail
-
getMomentsAgoString
public static java.lang.String getMomentsAgoString(java.util.Date pastDate, java.text.DateFormat format)
Returns "xago 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 pastformat
- The format for the pastDate- Returns:
- "x
ago on "
-
getMomentsAgoString
public static java.lang.String getMomentsAgoString(java.util.Date pastDate)
Returns "xago 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 java.lang.String handleUnit(java.util.Calendar then, java.util.Calendar now, java.lang.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 evaluatingnow
- The current timefield
- 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.
-
-