public enum DateFormats extends Enum<DateFormats>
DateFormats
represent sets of DateFormat
definitions.
Such a set is most useful to parse back a String
into a Date
when there are multiple possible String
representations. E.g. a
cookie's date representation might be either as defined by the
DateFormat.NETSCAPE_COOKIE_DATE_FORMAT
or by the
DateFormat.ALTERNATE_COOKIE_DATE_FORMAT
.Enum Constant and Description |
---|
COOKIE_DATE_FORMATS
Set of
DateFormat definitions commonly used by cookies. |
DEFAULT_DATE_FORMATS
Sound set of common
DateFormat definitions with no special
addressee. |
DEFAULT_DATE_FORMATS_SHORT
Sound set of common short
DateFormat definitions with no special
addressee. |
Modifier and Type | Method and Description |
---|---|
DateTimeFormatter[] |
getDateFormats()
Gets the date formats.
|
Date |
toDate(String aDateString)
Creates a date from the provided
String using the date formats as
retrieved by the getDateFormats() method. |
static DateFormats |
valueOf(String name)
Returns the enum constant of this type with the specified name.
|
static DateFormats[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final DateFormats DEFAULT_DATE_FORMATS
DateFormat
definitions with no special
addressee.public static final DateFormats DEFAULT_DATE_FORMATS_SHORT
DateFormat
definitions with no special
addressee.public static final DateFormats COOKIE_DATE_FORMATS
DateFormat
definitions commonly used by cookies.public static DateFormats[] values()
for (DateFormats c : DateFormats.values()) System.out.println(c);
public static DateFormats valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic DateTimeFormatter[] getDateFormats()
public Date toDate(String aDateString) throws DateTimeException
String
using the date formats as
retrieved by the getDateFormats()
method. If one date format
fails, then the next one is used to parse the date text.aDateString
- The date text to be converted to a Date
instance.Date
instance as of the date text.DateTimeException
- the date time exceptionCopyright © 2017. All rights reserved.