@Test public final void shouldParseShortestExpressionUp() throws ParseException { final String expr = "2013-5-2 9:3:2"; final boolean upComplete = true; final Date date = DateUtils.parseAndComplete(expr, upComplete); assertDateEquals(new DateTime(2013, 5, 2, 9, 3, 2, 999), date); }
public static Date parseAndComplete(final String dateExpression, final boolean upComplete) throws ParseException { final String trimmedDateExpression = StringUtils.trim(dateExpression); DateTime parsedDate = new DateTime(org.apache.commons.lang3.time.DateUtils.parseDateStrictly(trimmedDateExpression, SUPPORTED_PATTERNS)); final String[] dateAndTime = trimmedDateExpression.split(" "); if (dateAndTime.length > 2 || parsedDate.getYear() < 1500 || parsedDate.getYear() > 2500) { throw new ParseException(L_WRONG_DATE, 1); } return round(parsedDate, upComplete, dateAndTime).toDate(); }
DateUtils { public static Date parseAndComplete(final String dateExpression, final boolean upComplete) throws ParseException { final String trimmedDateExpression = StringUtils.trim(dateExpression); DateTime parsedDate = new DateTime(org.apache.commons.lang3.time.DateUtils.parseDateStrictly(trimmedDateExpression, SUPPORTED_PATTERNS)); final String[] dateAndTime = trimmedDateExpression.split(" "); if (dateAndTime.length > 2 || parsedDate.getYear() < 1500 || parsedDate.getYear() > 2500) { throw new ParseException(L_WRONG_DATE, 1); } return round(parsedDate, upComplete, dateAndTime).toDate(); } }
DateUtils { public static Date parseAndComplete(final String dateExpression, final boolean upComplete) throws ParseException { final String trimmedDateExpression = StringUtils.trim(dateExpression); DateTime parsedDate = new DateTime(org.apache.commons.lang3.time.DateUtils.parseDateStrictly(trimmedDateExpression, SUPPORTED_PATTERNS)); final String[] dateAndTime = trimmedDateExpression.split(" "); if (dateAndTime.length > 2 || parsedDate.getYear() < 1500 || parsedDate.getYear() > 2500) { throw new ParseException(L_WRONG_DATE, 1); } return round(parsedDate, upComplete, dateAndTime).toDate(); } private  DateUtils(); }
DateUtils { public static Date parseAndComplete(final String dateExpression, final boolean upComplete) throws ParseException { final String trimmedDateExpression = StringUtils.trim(dateExpression); DateTime parsedDate = new DateTime(org.apache.commons.lang3.time.DateUtils.parseDateStrictly(trimmedDateExpression, SUPPORTED_PATTERNS)); final String[] dateAndTime = trimmedDateExpression.split(" "); if (dateAndTime.length > 2 || parsedDate.getYear() < 1500 || parsedDate.getYear() > 2500) { throw new ParseException(L_WRONG_DATE, 1); } return round(parsedDate, upComplete, dateAndTime).toDate(); } private  DateUtils(); static Date parseAndComplete(final String dateExpression, final boolean upComplete); static String toDateTimeString(final Date date); static String toDateString(final Date date); static Date parseDate(final Object value); static Either<? extends Exception, Optional<DateTime>> tryParse(final Object value); static Date copy(final Date date); }
DateUtils { public static Date parseAndComplete(final String dateExpression, final boolean upComplete) throws ParseException { final String trimmedDateExpression = StringUtils.trim(dateExpression); DateTime parsedDate = new DateTime(org.apache.commons.lang3.time.DateUtils.parseDateStrictly(trimmedDateExpression, SUPPORTED_PATTERNS)); final String[] dateAndTime = trimmedDateExpression.split(" "); if (dateAndTime.length > 2 || parsedDate.getYear() < 1500 || parsedDate.getYear() > 2500) { throw new ParseException(L_WRONG_DATE, 1); } return round(parsedDate, upComplete, dateAndTime).toDate(); } private  DateUtils(); static Date parseAndComplete(final String dateExpression, final boolean upComplete); static String toDateTimeString(final Date date); static String toDateString(final Date date); static Date parseDate(final Object value); static Either<? extends Exception, Optional<DateTime>> tryParse(final Object value); static Date copy(final Date date); static final String L_DATE_FORMAT; static final String L_DATE_TIME_FORMAT; static final String L_REPORT_DATE_TIME_FORMAT; }