public final class DateUtility extends Object
Modifier and Type | Method and Description |
---|---|
static Date |
toDate(String aValue,
DateTimeFormatter[] aDateTimeFormatters)
Parses a
String to retrieve a date from it, using the provided
SimpleDateFormat instances. |
public static Date toDate(String aValue, DateTimeFormatter[] aDateTimeFormatters) throws ParseException
String
to retrieve a date from it, using the provided
SimpleDateFormat
instances. The first one being able to parse a
Date
from the String
will be used and that Date
is returned. If none SimpleDateFormat
instances were able to
parse the provided String
, then the first (as being provided in
the array) SimpleDateFormat
's parse exception is thrown.aValue
- The date String
to be parsed.aDateTimeFormatters
- The SimpleDateFormat
instances to be
tried out, starting with the first one.Date
retrieved from the given String
.ParseException
- Thrown in case none of the provided
SimpleDateFormat
instances was able to parse the string.
Then the first caught ParseException
is thrown.Copyright © 2016. All rights reserved.