- All Implemented Interfaces:
Serializable
,Comparable<DateFormats>
,java.lang.constant.Constable
The
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
.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionSet ofDateFormat
definitions commonly used by cookies.Sound set of commonDateFormat
definitions with no special addressee.Sound set of common shortDateFormat
definitions with no special addressee.Set ofDateFormat
definitions found in heterogeneous internet related services.Set of commonDateFormat
ISO definitions. -
Method Summary
Modifier and TypeMethodDescriptionstatic Date
Tries to create aDate
by harnessing theDateTimeFormatter
instances known by this enumeration.static LocalDate
asLocalDate
(String aDateString) Tries to create aLocalDate
by harnessing theDateTimeFormatter
instances known by this enumeration.static LocalDateTime
asLocalDateTime
(String aDateString) Tries to create aLocalDateTime
by harnessing theDateTimeFormatter
instances known by this enumeration.Gets the date formats.Creates aDate
from the providedString
using the date formats as retrieved by thegetDateFormats()
method.toLocalDate
(String aDateString) Creates aLocalDate
from the providedString
using the date formats as retrieved by thegetDateFormats()
method.toLocalDateTime
(String aDateString) Creates aLocalDateTime
from the providedString
using the date formats as retrieved by thegetDateFormats()
method.static DateFormats
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.
-
Enum Constant Details
-
DEFAULT_DATE_FORMATS
Sound set of commonDateFormat
definitions with no special addressee. -
DEFAULT_DATE_FORMATS_SHORT
Sound set of common shortDateFormat
definitions with no special addressee. -
COOKIE_DATE_FORMATS
Set ofDateFormat
definitions commonly used by cookies. -
INTERNET_DATE_FORMATS
Set ofDateFormat
definitions found in heterogeneous internet related services. -
ISO_DATE_FORMATS
Set of commonDateFormat
ISO definitions.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
getDateFormats
Gets the date formats.- Returns:
- the date formats
-
toDate
Creates aDate
from the providedString
using the date formats as retrieved by thegetDateFormats()
method. If one date format fails, then the next one is used to parse the date text.- Parameters:
aDateString
- The date text to be converted to aDate
instance.- Returns:
- The
Date
instance as of the date text. - Throws:
DateTimeException
- Thrown in case none of the providedDateTimeFormatter
instances was able to parse the string. Then the first caughtDateTimeException
is thrown.
-
toLocalDate
Creates aLocalDate
from the providedString
using the date formats as retrieved by thegetDateFormats()
method. If one date format fails, then the next one is used to parse the date text.- Parameters:
aDateString
- The date text to be converted to aDate
instance.- Returns:
- The
Date
instance as of the date text. - Throws:
DateTimeException
- Thrown in case none of the providedDateTimeFormatter
instances was able to parse the string. Then the first caughtDateTimeException
is thrown.
-
toLocalDateTime
Creates aLocalDateTime
from the providedString
using the date formats as retrieved by thegetDateFormats()
method. If one date format fails, then the next one is used to parse the date text.- Parameters:
aDateString
- The date text to be converted to aDate
instance.- Returns:
- The
Date
instance as of the date text. - Throws:
DateTimeException
- Thrown in case none of the providedDateTimeFormatter
instances was able to parse the string. Then the first caughtDateTimeException
is thrown.
-
asDate
Tries to create aDate
by harnessing theDateTimeFormatter
instances known by this enumeration.- Parameters:
aDateString
- The date text to be converted to aDate
instance.- Returns:
- The
Date
instance as of the date text. - Throws:
DateTimeException
- Thrown in case none of the providedDateTimeFormatter
instances was able to parse the string. Then the first caughtDateTimeException
is thrown.
-
asLocalDate
Tries to create aLocalDate
by harnessing theDateTimeFormatter
instances known by this enumeration.- Parameters:
aDateString
- The date text to be converted to aLocalDate
instance.- Returns:
- The
LocalDate
instance as of the date text. - Throws:
DateTimeException
- Thrown in case none of the providedDateTimeFormatter
instances was able to parse the string. Then the first caughtDateTimeException
is thrown.
-
asLocalDateTime
Tries to create aLocalDateTime
by harnessing theDateTimeFormatter
instances known by this enumeration.- Parameters:
aDateString
- The date text to be converted to aLocalDate
instance.- Returns:
- The
LocalDateTime
instance as of the date text. - Throws:
DateTimeException
- Thrown in case none of the providedDateTimeFormatter
instances was able to parse the string. Then the first caughtDateTimeException
is thrown.
-