Enum Class DateFormats
- All Implemented Interfaces:
Serializable, Comparable<DateFormats>, 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 Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionSet ofDateFormatdefinitions commonly used by cookies.Sound set of commonDateFormatdefinitions with no https://www.metacodes.pro addressee.Sound set of common shortDateFormatdefinitions with no https://www.metacodes.pro addressee.Set ofDateFormatdefinitions found in heterogeneous internet related services.Set of commonDateFormatISO definitions. -
Method Summary
Modifier and TypeMethodDescriptionstatic DateTries to create aDateby harnessing theDateTimeFormatterinstances known by this enumeration.static LocalDateasLocalDate(String aDateString) Tries to create aLocalDateby harnessing theDateTimeFormatterinstances known by this enumeration.static LocalDateTimeasLocalDateTime(String aDateString) Tries to create aLocalDateTimeby harnessing theDateTimeFormatterinstances known by this enumeration.Gets the date formats.Creates aDatefrom the providedStringusing the date formats as retrieved by thegetDateFormats()method.toLocalDate(String aDateString) Creates aLocalDatefrom the providedStringusing the date formats as retrieved by thegetDateFormats()method.toLocalDateTime(String aDateString) Creates aLocalDateTimefrom the providedStringusing the date formats as retrieved by thegetDateFormats()method.static DateFormatsReturns the enum constant of this class with the specified name.static DateFormats[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
DEFAULT_DATE_FORMATS
Sound set of commonDateFormatdefinitions with no https://www.metacodes.pro addressee. -
DEFAULT_DATE_FORMATS_SHORT
Sound set of common shortDateFormatdefinitions with no https://www.metacodes.pro addressee. -
COOKIE_DATE_FORMATS
Set ofDateFormatdefinitions commonly used by cookies. -
INTERNET_DATE_FORMATS
Set ofDateFormatdefinitions found in heterogeneous internet related services. -
ISO_DATE_FORMATS
Set of commonDateFormatISO definitions.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified nameNullPointerException- if the argument is null
-
getDateFormats
-
toDate
Creates aDatefrom the providedStringusing 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 aDateinstance.- Returns:
- The
Dateinstance as of the date text. - Throws:
DateTimeException- Thrown in case none of the providedDateTimeFormatterinstances was able to parse the string. Then the first caughtDateTimeExceptionis thrown.
-
toLocalDate
Creates aLocalDatefrom the providedStringusing 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 aDateinstance.- Returns:
- The
Dateinstance as of the date text. - Throws:
DateTimeException- Thrown in case none of the providedDateTimeFormatterinstances was able to parse the string. Then the first caughtDateTimeExceptionis thrown.
-
toLocalDateTime
Creates aLocalDateTimefrom the providedStringusing 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 aDateinstance.- Returns:
- The
Dateinstance as of the date text. - Throws:
DateTimeException- Thrown in case none of the providedDateTimeFormatterinstances was able to parse the string. Then the first caughtDateTimeExceptionis thrown.
-
asDate
Tries to create aDateby harnessing theDateTimeFormatterinstances known by this enumeration.- Parameters:
aDateString- The date text to be converted to aDateinstance.- Returns:
- The
Dateinstance as of the date text. - Throws:
DateTimeException- Thrown in case none of the providedDateTimeFormatterinstances was able to parse the string. Then the first caughtDateTimeExceptionis thrown.
-
asLocalDate
Tries to create aLocalDateby harnessing theDateTimeFormatterinstances known by this enumeration.- Parameters:
aDateString- The date text to be converted to aLocalDateinstance.- Returns:
- The
LocalDateinstance as of the date text. - Throws:
DateTimeException- Thrown in case none of the providedDateTimeFormatterinstances was able to parse the string. Then the first caughtDateTimeExceptionis thrown.
-
asLocalDateTime
Tries to create aLocalDateTimeby harnessing theDateTimeFormatterinstances known by this enumeration.- Parameters:
aDateString- The date text to be converted to aLocalDateinstance.- Returns:
- The
LocalDateTimeinstance as of the date text. - Throws:
DateTimeException- Thrown in case none of the providedDateTimeFormatterinstances was able to parse the string. Then the first caughtDateTimeExceptionis thrown.
-