public class RelativeDateFormat extends DateFormat
DateFormat.Field
AM_PM_FIELD, 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, 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(Date time)
Creates a new instance.
|
RelativeDateFormat(long baseMillis)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Returns a clone of this instance.
|
boolean |
equals(Object obj)
Tests this formatter for equality with an arbitrary object.
|
StringBuffer |
format(Date date,
StringBuffer toAppendTo,
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.
|
String |
getDaySuffix()
Returns the string that is appended to the day count.
|
String |
getHourSuffix()
Returns the string that is appended to the hour count.
|
String |
getMinuteSuffix()
Returns the string that is appended to the minute count.
|
String |
getPositivePrefix()
Returns the string that is prepended to the format if the relative time
is positive.
|
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.
|
Date |
parse(String source,
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(NumberFormat formatter)
Sets the formatter for the days.
|
void |
setDaySuffix(String suffix)
Sets the string that is appended to the day count.
|
void |
setHourFormatter(NumberFormat formatter)
Sets the formatter for the hours.
|
void |
setHourSuffix(String suffix)
Sets the string that is appended to the hour count.
|
void |
setMinuteFormatter(NumberFormat formatter)
Sets the formatter for the minutes.
|
void |
setMinuteSuffix(String suffix)
Sets the string that is appended to the minute count.
|
void |
setPositivePrefix(String prefix)
Sets the string that is prepended to the format if the relative time is
positive.
|
void |
setSecondFormatter(NumberFormat formatter)
Sets the formatter for the seconds and milliseconds.
|
void |
setSecondSuffix(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, setTimeZone
format, formatToCharacterIterator, parseObject
public RelativeDateFormat()
public RelativeDateFormat(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 String getPositivePrefix()
null
).setPositivePrefix(String)
public void setPositivePrefix(String prefix)
prefix
- the prefix (null
not permitted).getPositivePrefix()
public void setDayFormatter(NumberFormat formatter)
formatter
- the formatter (null
not permitted).public String getDaySuffix()
setDaySuffix(String)
public void setDaySuffix(String suffix)
suffix
- the suffix (null
not permitted).getDaySuffix()
public void setHourFormatter(NumberFormat formatter)
formatter
- the formatter (null
not permitted).public String getHourSuffix()
setHourSuffix(String)
public void setHourSuffix(String suffix)
suffix
- the suffix (null
not permitted).getHourSuffix()
public void setMinuteFormatter(NumberFormat formatter)
formatter
- the formatter (null
not permitted).public String getMinuteSuffix()
setMinuteSuffix(String)
public void setMinuteSuffix(String suffix)
suffix
- the suffix (null
not permitted).getMinuteSuffix()
public String getSecondSuffix()
setSecondSuffix(String)
public void setSecondSuffix(String suffix)
suffix
- the suffix (null
not permitted).getSecondSuffix()
public void setSecondFormatter(NumberFormat formatter)
formatter
- the formatter (null
not permitted).public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition)
format
in class DateFormat
date
- the date.toAppendTo
- the string buffer.fieldPosition
- the field position.public Date parse(String source, ParsePosition pos)
parse
in class DateFormat
source
- the date string.pos
- the parse position.null
, as this method has not been implemented.public boolean equals(Object obj)
equals
in class DateFormat
obj
- the object (null
permitted).public int hashCode()
hashCode
in class DateFormat
public Object clone()
clone
in class DateFormat
Jas4pp 1.5 © Java Analysis Studio for Particle Physics