Package org.refcodes.time
Class DateUtility
- java.lang.Object
-
- org.refcodes.time.DateUtility
-
public final class DateUtility extends java.lang.Object
The Class DateUtility.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Date
toDate(java.lang.String aValue, java.time.format.DateTimeFormatter[] aDateTimeFormatters)
Parses aString
to retrieve a date from it, using the providedDateTimeFormatter
instances.
-
-
-
Method Detail
-
toDate
public static java.util.Date toDate(java.lang.String aValue, java.time.format.DateTimeFormatter[] aDateTimeFormatters) throws java.text.ParseException
Parses aString
to retrieve a date from it, using the providedDateTimeFormatter
instances. The first one being able to parse aDate
from theString
will be used and thatDate
is returned. If noneDateTimeFormatter
instances were able to parse the providedString
, then the first (as being provided in the array)DateTimeFormatter
's parse exception is thrown.- Parameters:
aValue
- The dateString
to be parsed.aDateTimeFormatters
- TheDateTimeFormatter
instances to be tried out, starting with the first one.- Returns:
- A
Date
retrieved from the givenString
. - Throws:
java.text.ParseException
- Thrown in case none of the providedDateTimeFormatter
instances was able to parse the string. Then the first caughtParseException
is thrown.
-
-