public class RelativeDateFormat extends DateFormat
| Modifier and Type | Class and Description |
|---|---|
static class |
RelativeDateFormat.URelativeString |
DateFormat.BooleanAttribute, DateFormat.Field, DateFormat.HourCycleUFormat.SpanFieldABBR_GENERIC_TZ, ABBR_MONTH, ABBR_MONTH_DAY, ABBR_MONTH_WEEKDAY_DAY, ABBR_QUARTER, ABBR_SPECIFIC_TZ, ABBR_UTC_TZ, ABBR_WEEKDAY, AM_PM_FIELD, AM_PM_MIDNIGHT_NOON_FIELD, calendar, DATE_FIELD, DAY, DAY_OF_WEEK_FIELD, DAY_OF_WEEK_IN_MONTH_FIELD, DAY_OF_YEAR_FIELD, DEFAULT, DOW_LOCAL_FIELD, ERA_FIELD, EXTENDED_YEAR_FIELD, FLEXIBLE_DAY_PERIOD_FIELD, FRACTIONAL_SECOND_FIELD, FULL, GENERIC_TZ, HOUR, HOUR_MINUTE, HOUR_MINUTE_SECOND, HOUR_OF_DAY0_FIELD, HOUR_OF_DAY1_FIELD, HOUR0_FIELD, HOUR1_FIELD, HOUR24, HOUR24_MINUTE, HOUR24_MINUTE_SECOND, JULIAN_DAY_FIELD, LOCATION_TZ, LONG, MEDIUM, MILLISECOND_FIELD, MILLISECONDS_IN_DAY_FIELD, MINUTE, MINUTE_FIELD, MINUTE_SECOND, MONTH, MONTH_DAY, MONTH_FIELD, MONTH_WEEKDAY_DAY, NONE, NUM_MONTH, NUM_MONTH_DAY, NUM_MONTH_WEEKDAY_DAY, numberFormat, QUARTER, QUARTER_FIELD, RELATIVE, RELATIVE_DEFAULT, RELATIVE_FULL, RELATIVE_LONG, RELATIVE_MEDIUM, RELATIVE_SHORT, SECOND, SECOND_FIELD, SHORT, SPECIFIC_TZ, STANDALONE_DAY_FIELD, STANDALONE_MONTH_FIELD, STANDALONE_QUARTER_FIELD, TIMEZONE_FIELD, TIMEZONE_GENERIC_FIELD, TIMEZONE_ISO_FIELD, TIMEZONE_ISO_LOCAL_FIELD, TIMEZONE_LOCALIZED_GMT_OFFSET_FIELD, TIMEZONE_RFC_FIELD, TIMEZONE_SPECIAL_FIELD, WEEK_OF_MONTH_FIELD, WEEK_OF_YEAR_FIELD, WEEKDAY, YEAR, YEAR_ABBR_MONTH, YEAR_ABBR_MONTH_DAY, YEAR_ABBR_MONTH_WEEKDAY_DAY, YEAR_ABBR_QUARTER, YEAR_FIELD, YEAR_MONTH, YEAR_MONTH_DAY, YEAR_MONTH_WEEKDAY_DAY, YEAR_NAME_FIELD, YEAR_NUM_MONTH, YEAR_NUM_MONTH_DAY, YEAR_NUM_MONTH_WEEKDAY_DAY, YEAR_QUARTER, YEAR_WOY_FIELD| Constructor and Description |
|---|
RelativeDateFormat(int timeStyle,
int dateStyle,
ULocale locale,
Calendar cal) |
| Modifier and Type | Method and Description |
|---|---|
StringBuffer |
format(Calendar cal,
StringBuffer toAppendTo,
FieldPosition fieldPosition)
Formats a date into a date/time string.
|
void |
parse(String text,
Calendar cal,
ParsePosition pos)
Parses a date/time string according to the given parse position.
|
void |
setContext(DisplayContext context)
Set a particular DisplayContext value in the formatter,
such as CAPITALIZATION_FOR_STANDALONE.
|
clone, equals, format, format, format, getAvailableLocales, getAvailableULocales, getBooleanAttribute, getCalendar, getContext, getDateInstance, getDateInstance, getDateInstance, getDateInstance, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getInstance, getInstance, getInstance, getInstanceForSkeleton, getInstanceForSkeleton, getInstanceForSkeleton, getInstanceForSkeleton, getInstanceForSkeleton, getNumberFormat, getPatternInstance, getPatternInstance, getPatternInstance, getPatternInstance, getPatternInstance, getTimeInstance, getTimeInstance, getTimeInstance, getTimeInstance, getTimeInstance, getTimeInstance, getTimeInstance, getTimeZone, hashCode, isCalendarLenient, isLenient, parse, parse, parseObject, setBooleanAttribute, setCalendar, setCalendarLenient, setLenient, setNumberFormat, setTimeZoneformat, formatToCharacterIterator, parseObjectpublic StringBuffer format(Calendar cal, StringBuffer toAppendTo, FieldPosition fieldPosition)
DateFormatformat in class DateFormatcal - a Calendar set to the date and time to be formatted
into a date/time string. When the calendar type is different from
the internal calendar held by this DateFormat instance, the date
and the time zone will be inherited from the input calendar, but
other calendar field values will be calculated by the internal calendar.toAppendTo - the string buffer for the returning date/time string.fieldPosition - keeps track of the position of the field
within the returned string.
On input: an alignment field,
if desired. On output: the offsets of the alignment field. For
example, given a time text "1996.07.10 AD at 15:08:56 PDT",
if the given fieldPosition is DateFormat.YEAR_FIELD, the
begin index and end index of fieldPosition will be set to
0 and 4, respectively.
Notice that if the same time field appears
more than once in a pattern, the fieldPosition will be set for the first
occurrence of that time field. For instance, formatting a Date to
the time string "1 PM PDT (Pacific Daylight Time)" using the pattern
"h a z (zzzz)" and the alignment field DateFormat.TIMEZONE_FIELD,
the begin index and end index of fieldPosition will be set to
5 and 8, respectively, for the first occurrence of the timezone
pattern character 'z'.public void parse(String text, Calendar cal, ParsePosition pos)
DateFormatBy default, parsing is lenient: If the input is not in the form used by this object's format method but can still be parsed as a date, then the parse succeeds. Clients may insist on strict adherence to the format by calling setLenient(false).
parse in class DateFormattext - The date/time string to be parsedcal - The calendar set on input to the date and time to be used
for missing values in the date/time string being parsed,
and set on output to the parsed date/time. In general, this
should be initialized before calling this method - either
cleared or set to the current date, depending on desired
behavior. If this parse fails, the calendar may still
have been modified. When the calendar type is different
from the internal calendar held by this DateFormat
instance, calendar field values will be parsed based
on the internal calendar initialized with the time and
the time zone taken from this calendar, then the
parse result (time in milliseconds and time zone) will
be set back to this calendar.pos - 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.DateFormat.setLenient(boolean)public void setContext(DisplayContext context)
DateFormatsetContext in class DateFormatcontext - The DisplayContext value to set.