Class MomentsAgoDateFormatter
java.lang.Object
com.biglybt.core.metasearch.utils.MomentsAgoDateFormatter
Improvement based on AZWEB-318.
- Since:
- 3.2.1.0 6/19/2007
- Version:
- 3.2.1.0 6/19/2007
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final Mapprivate static final Integerprivate static final Integerprivate static final Integerprivate static final Integerprivate static final Integerprivate static final Integerprivate static final Integerprivate static final Longprivate static final Longprivate static final Longprivate static final Longprivate static final Longprivate static final Longprivate static final Longprivate static final Stringprivate static final Map -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetMomentsAgoString(Date pastDate) Returns "xago on " by comparing the given pastDate with the current time. static StringgetMomentsAgoString(Date pastDate, DateFormat format) Returns "xago on " by comparing the given pastDate with the current time. private static StringhandleUnit(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.
-
Field Details
-
ID_YEAR
-
ID_MONTH
-
ID_WEEK_OF_YEAR
-
ID_DAY
-
ID_HOUR_OF_DAY
-
ID_MINUTE
-
ID_SECOND
-
MS_IN_YEAR
-
MS_IN_MONTH
-
MS_IN_WEEK
-
MS_IN_DAY
-
MS_IN_HOUR
-
MS_IN_MINUTE
-
MS_IN_SECOND
-
AGO
- See Also:
-
PLURAL
- See Also:
-
CONVERSION_MAP
-
UNIT_MAP
-
-
Constructor Details
-
MomentsAgoDateFormatter
public MomentsAgoDateFormatter()
-
-
Method Details
-
getMomentsAgoString
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
-
handleUnit
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.
-