public class RelativeDateFormat
extends java.text.DateFormat
Modifier and Type | Class and Description |
---|---|
static class |
RelativeDateFormat.RelativeType |
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()
Create a new RelativeDateFormat with a default pattern.
|
RelativeDateFormat(java.lang.String datePattern)
Create a new RelativeDateFormat with the given pattern.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj)
Overrides equals
|
java.lang.StringBuffer |
format(java.util.Date date,
java.lang.StringBuffer toAppendTo,
java.text.FieldPosition fieldPosition)
Formats a date into a date/time string
|
java.util.Date |
getReferenceDate()
Get the date that this DateFormat uses as a reference.
|
RelativeDateFormat.RelativeType |
getRelationMethod()
Get the relation method to be used when interpreting inexact dates.
|
int |
hashCode()
Overrides hashCode
|
java.util.Date |
parse(java.lang.String text,
java.text.ParsePosition pos)
Parse a date/time string according to the given parse position.
|
void |
setReferenceDate(java.util.Date referenceDate)
Set the date that this DateFormat uses as a reference.
|
void |
setRelationMethod(RelativeDateFormat.RelativeType method)
Set the relation method to be used when interpreting inexact dates.
|
java.lang.String |
toPattern()
Return the pattern defining this RelativeDateFormat
|
clone, format, format, getAvailableLocales, getCalendar, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getNumberFormat, getTimeInstance, getTimeInstance, getTimeInstance, getTimeZone, isLenient, parse, parseObject, setCalendar, setLenient, setNumberFormat, setTimeZone
public RelativeDateFormat()
public RelativeDateFormat(java.lang.String datePattern)
datePattern
- the pattern for this DateFormatpublic boolean equals(java.lang.Object obj)
equals
in class java.text.DateFormat
obj
- an object to compare this one topublic java.lang.StringBuffer format(java.util.Date date, java.lang.StringBuffer toAppendTo, java.text.FieldPosition fieldPosition)
format
in class java.text.DateFormat
date
- a Date to be formatted into a date/time string.toAppendTo
- the string buffer for the returning date/time string.fieldPosition
- keeps track of the position of the field within the
returned stringpublic java.util.Date getReferenceDate()
public RelativeDateFormat.RelativeType getRelationMethod()
public int hashCode()
hashCode
in class java.text.DateFormat
public java.util.Date parse(java.lang.String text, java.text.ParsePosition pos)
parse
in class java.text.DateFormat
text
- The date/time string to be parsedpos
- On input, the position at which to start parsing; on output,
the position at which parsing terminated, or the start
position if the parse failed.public void setReferenceDate(java.util.Date referenceDate)
referenceDate
- the new reference datepublic void setRelationMethod(RelativeDateFormat.RelativeType method)
method
- the relation methodpublic java.lang.String toPattern()