public class RelativeDateFormat extends java.text.DateFormat
AM_PM_FIELD, calendar, DATE_FIELD, DAY_OF_WEEK_FIELD, DAY_OF_WEEK_IN_MONTH_FIELD, DAY_OF_YEAR_FIELD, DEFAULT, ERA_FIELD, FULL, HOUR_OF_DAY0_FIELD, HOUR_OF_DAY1_FIELD, HOUR0_FIELD, HOUR1_FIELD, LONG, MEDIUM, MILLISECOND_FIELD, MINUTE_FIELD, MONTH_FIELD, numberFormat, SECOND_FIELD, SHORT, TIMEZONE_FIELD, WEEK_OF_MONTH_FIELD, WEEK_OF_YEAR_FIELD, YEAR_FIELD| Constructor and Description |
|---|
RelativeDateFormat()
Creates a new instance with base milliseconds set to zero.
|
RelativeDateFormat(java.util.Date time)
Creates a new instance.
|
RelativeDateFormat(long baseMillis)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
clone()
Returns a clone of this instance.
|
boolean |
equals(java.lang.Object obj)
Tests this formatter for equality with an arbitrary object.
|
java.lang.StringBuffer |
format(java.util.Date date,
java.lang.StringBuffer toAppendTo,
java.text.FieldPosition fieldPosition)
Formats the given date as the amount of elapsed time (relative to the
base date specified in the constructor).
|
long |
getBaseMillis()
Returns the base date/time used to calculate the elapsed time for
display.
|
java.lang.String |
getDaySuffix()
Returns the string that is appended to the day count.
|
java.lang.String |
getHourSuffix()
Returns the string that is appended to the hour count.
|
java.lang.String |
getMinuteSuffix()
Returns the string that is appended to the minute count.
|
java.lang.String |
getPositivePrefix()
Returns the string that is prepended to the format if the relative time
is positive.
|
java.lang.String |
getSecondSuffix()
Returns the string that is appended to the second count.
|
boolean |
getShowZeroDays()
Returns the flag that controls whether or not zero day counts are
shown in the formatted output.
|
boolean |
getShowZeroHours()
Returns the flag that controls whether or not zero hour counts are
shown in the formatted output.
|
int |
hashCode()
Returns a hash code for this instance.
|
java.util.Date |
parse(java.lang.String source,
java.text.ParsePosition pos)
Parses the given string (not implemented).
|
void |
setBaseMillis(long baseMillis)
Sets the base date/time used to calculate the elapsed time for display.
|
void |
setDayFormatter(java.text.NumberFormat formatter)
Sets the formatter for the days.
|
void |
setDaySuffix(java.lang.String suffix)
Sets the string that is appended to the day count.
|
void |
setHourFormatter(java.text.NumberFormat formatter)
Sets the formatter for the hours.
|
void |
setHourSuffix(java.lang.String suffix)
Sets the string that is appended to the hour count.
|
void |
setMinuteFormatter(java.text.NumberFormat formatter)
Sets the formatter for the minutes.
|
void |
setMinuteSuffix(java.lang.String suffix)
Sets the string that is appended to the minute count.
|
void |
setPositivePrefix(java.lang.String prefix)
Sets the string that is prepended to the format if the relative time is
positive.
|
void |
setSecondFormatter(java.text.NumberFormat formatter)
Sets the formatter for the seconds and milliseconds.
|
void |
setSecondSuffix(java.lang.String suffix)
Sets the string that is appended to the second count.
|
void |
setShowZeroDays(boolean show)
Sets the flag that controls whether or not zero day counts are shown
in the formatted output.
|
void |
setShowZeroHours(boolean show)
Sets the flag that controls whether or not zero hour counts are shown
in the formatted output.
|
format, format, getAvailableLocales, getCalendar, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getNumberFormat, getTimeInstance, getTimeInstance, getTimeInstance, getTimeZone, isLenient, parse, parseObject, setCalendar, setLenient, setNumberFormat, setTimeZonepublic RelativeDateFormat()
public RelativeDateFormat(java.util.Date time)
time - the date/time (null not permitted).public RelativeDateFormat(long baseMillis)
baseMillis - the time zone (null not permitted).public long getBaseMillis()
setBaseMillis(long)public void setBaseMillis(long baseMillis)
java.util.Date.baseMillis - the base date/time in milliseconds.getBaseMillis()public boolean getShowZeroDays()
setShowZeroDays(boolean)public void setShowZeroDays(boolean show)
show - the flag.getShowZeroDays()public boolean getShowZeroHours()
setShowZeroHours(boolean)public void setShowZeroHours(boolean show)
show - the flag.getShowZeroHours()public java.lang.String getPositivePrefix()
null).setPositivePrefix(String)public void setPositivePrefix(java.lang.String prefix)
prefix - the prefix (null not permitted).getPositivePrefix()public void setDayFormatter(java.text.NumberFormat formatter)
formatter - the formatter (null not permitted).public java.lang.String getDaySuffix()
setDaySuffix(String)public void setDaySuffix(java.lang.String suffix)
suffix - the suffix (null not permitted).getDaySuffix()public void setHourFormatter(java.text.NumberFormat formatter)
formatter - the formatter (null not permitted).public java.lang.String getHourSuffix()
setHourSuffix(String)public void setHourSuffix(java.lang.String suffix)
suffix - the suffix (null not permitted).getHourSuffix()public void setMinuteFormatter(java.text.NumberFormat formatter)
formatter - the formatter (null not permitted).public java.lang.String getMinuteSuffix()
setMinuteSuffix(String)public void setMinuteSuffix(java.lang.String suffix)
suffix - the suffix (null not permitted).getMinuteSuffix()public java.lang.String getSecondSuffix()
setSecondSuffix(String)public void setSecondSuffix(java.lang.String suffix)
suffix - the suffix (null not permitted).getSecondSuffix()public void setSecondFormatter(java.text.NumberFormat formatter)
formatter - the formatter (null not permitted).public java.lang.StringBuffer format(java.util.Date date, java.lang.StringBuffer toAppendTo, java.text.FieldPosition fieldPosition)
format in class java.text.DateFormatdate - the date.toAppendTo - the string buffer.fieldPosition - the field position.public java.util.Date parse(java.lang.String source, java.text.ParsePosition pos)
parse in class java.text.DateFormatsource - the date string.pos - the parse position.null, as this method has not been implemented.public boolean equals(java.lang.Object obj)
equals in class java.text.DateFormatobj - the object (null permitted).public int hashCode()
hashCode in class java.text.DateFormatpublic java.lang.Object clone()
clone in class java.text.DateFormat