List of usage examples for org.apache.commons.lang3.time DateUtils parseDate
public static Date parseDate(final String str, final Locale locale, final String... parsePatterns) throws ParseException
Parses a string representing a date by trying a variety of different parsers, using the default date format symbols for the given locale.
The parse will try each parse pattern in turn.
From source file:com.stratelia.webactiv.util.DateUtil.java
/** * Parses the specified ISO 8601 formatted date and returns it as a Date instance. * @param date the date to parse (must satisfy one of the following pattern yyyy-MM-ddTHH:mm or * yyyy-MM-dd)./*from w ww .j a v a 2s. c o m*/ * @return a date object, resulting of the parsing. * @throws ParseException if the specified date is not in the one of the expected formats. */ public static Date parseISO8601Date(final String date) throws ParseException { return DateUtils.parseDate(date, ISO8601DATE_FORMATTER.getPattern(), ISO8601DAY_FORMATTER.getPattern()); }
From source file:uk.gov.gchq.koryphe.util.DateUtilTest.java
private void assertDate(final String expected, final String testDate, final String format) throws ParseException { assertEquals("Failed to parse date: " + testDate, DateUtils.parseDate(expected, Locale.getDefault(), format), DateUtil.parse(testDate)); }