public class PeriodCounter extends Object
Additional locales are supported through SPI interface.
The META-INF/services/org.foxlabs.util.PeriodCounter file
should be used to list new counters.
| Modifier and Type | Field and Description |
|---|---|
static PeriodCounter |
ENGLISH
PeriodCounter instance for english locale. |
protected Locale |
locale
Locale of this counter.
|
static PeriodCounter |
RUSSIAN
PeriodCounter instance for russian locale. |
| Modifier | Constructor and Description |
|---|---|
protected |
PeriodCounter(Locale locale)
Constructs a new
PeriodCounter with the specified locale. |
| Modifier and Type | Method and Description |
|---|---|
String |
evaluate(Date date)
Evaluates period string for the specified date.
|
protected String |
getDayPeriod(int count,
boolean future)
Returns period string in days (less than 1 week).
|
protected String |
getHourPeriod(int count,
boolean future)
Returns period string in hours (less than 1 day).
|
Locale |
getLocale()
Returns locale of this counter.
|
protected String |
getMinutePeriod(int count,
boolean future)
Returns period string in minutes (less than 1 hour).
|
protected String |
getMonthPeriod(int count,
boolean future)
Returns period string in months (less than 1 year).
|
protected String |
getNowPeriod()
Returns period string for now (less than 1 minute).
|
protected String |
getWeekPeriod(int count,
boolean future)
Returns period string in weeks (less than 1 month).
|
protected String |
getYearPeriod(int count,
boolean future)
Returns period string in years.
|
static String |
period(Date date)
Returns period string for the specified date and default locale.
|
static String |
period(Date date,
Locale locale)
Returns period string for the specified date and locale.
|
protected final Locale locale
public static final PeriodCounter ENGLISH
PeriodCounter instance for english locale.public static final PeriodCounter RUSSIAN
PeriodCounter instance for russian locale.protected PeriodCounter(Locale locale)
PeriodCounter with the specified locale.locale - Locale of this counter.public final Locale getLocale()
public final String evaluate(Date date)
date - Date for which period string should be evaluated.protected String getNowPeriod()
protected String getMinutePeriod(int count, boolean future)
count - Number of minutes.future - Determines if the specified period is past or future.protected String getHourPeriod(int count, boolean future)
count - Number of hours.future - Determines if the specified period is past or future.protected String getDayPeriod(int count, boolean future)
count - Number of days.future - Determines if the specified period is past or future.protected String getWeekPeriod(int count, boolean future)
count - Number of weeks.future - Determines if the specified period is past or future.protected String getMonthPeriod(int count, boolean future)
count - Number of months.future - Determines if the specified period is past or future.protected String getYearPeriod(int count, boolean future)
count - Number of years.future - Determines if the specified period is past or future.public static String period(Date date)
date - Date for which period should be returned.period(Date, Locale)Copyright © 2010-2012 FoxLabs. All Rights Reserved.