|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.text.Format
java.text.DateFormat
java.text.SimpleDateFormat
dsto.dfc.text.MultiDateFormat
public class MultiDateFormat
Title: MultiDateFormat Description: MultiDateFormat is DateFormat defined with more than one format. It parses using all of these formats, but formats using only the one. Parsing is done in order as given in the constructor. If you provide two formats that could read the same date, this class will use the first one. If you have extended versions of the pattern, i.e. YYYY-MM-DD and YYYY-MM-DD T hh:mm, you should place the longer ones first.
Copyright: Copyright (c) 2001
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.text.DateFormat |
|---|
DateFormat.Field |
| Field Summary | |
|---|---|
protected DateFormat |
defaultFormat
The format to use to create a String from a Date. |
protected DateFormat[] |
parseFormat
List of possible formats with which to parse a String |
| Fields inherited from class 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 Summary | |
|---|---|
MultiDateFormat(DateFormat[] someParseFormats)
Construct a MultiDateFormat using the given DateFormats and setting the default format pattern. |
|
MultiDateFormat(DateFormat[] someParseFormats,
DateFormat aDefaultFormat)
Construct a MultiDateFormat using the given DateFormats. |
|
| Method Summary | |
|---|---|
StringBuffer |
format(Date date,
StringBuffer toAppendTo,
FieldPosition fieldPosition)
Formats a Date into a date/time string using the default format. |
Date |
parse(String text,
ParsePosition pos)
Overrides DateFormat.parse to try all possible formats |
Object |
parseObject(String source)
Format.parseObject () generates useless generic message on error. |
void |
setDefaultFormat(DateFormat aFormat)
Set a different DateFormat as the format to use when calling format. |
| Methods inherited from class java.text.SimpleDateFormat |
|---|
applyLocalizedPattern, applyPattern, clone, equals, formatToCharacterIterator, get2DigitYearStart, getDateFormatSymbols, hashCode, set2DigitYearStart, setDateFormatSymbols, toLocalizedPattern, toPattern |
| Methods inherited from class java.text.DateFormat |
|---|
format, format, getAvailableLocales, getCalendar, getDateInstance, getDateInstance, getDateInstance, getDateTimeInstance, getDateTimeInstance, getDateTimeInstance, getInstance, getNumberFormat, getTimeInstance, getTimeInstance, getTimeInstance, getTimeZone, isLenient, parse, parseObject, setCalendar, setLenient, setNumberFormat, setTimeZone |
| Methods inherited from class java.text.Format |
|---|
format |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected DateFormat[] parseFormat
protected DateFormat defaultFormat
| Constructor Detail |
|---|
public MultiDateFormat(DateFormat[] someParseFormats,
DateFormat aDefaultFormat)
someParseFormats - an array of formats which to try in order
when parsing.aDefaultFormat - the format to use create a String from a
Date.SimpleDateFormatpublic MultiDateFormat(DateFormat[] someParseFormats)
SimpleDateFormat| Method Detail |
|---|
public StringBuffer format(Date date,
StringBuffer toAppendTo,
FieldPosition fieldPosition)
format in class SimpleDateFormatdate - a Date to for formatting into a date/time string.toAppendTo - the string buffer in which return a date/time
string.fieldPosition - contains the position of the field within
the returned string. On input: an alignment field, if
desired. On output: the offsets of the requested field.
DateFormat
public Object parseObject(String source)
throws ParseException
parseObject in class FormatParseException
public Date parse(String text,
ParsePosition pos)
parse in class SimpleDateFormatDateFormatpublic void setDefaultFormat(DateFormat aFormat)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||