List of usage examples for org.apache.commons.lang.time DateUtils parseDateStrictly
public static Date parseDateStrictly(String str, String... parsePatterns) throws ParseException
Parses a string representing a date by trying a variety of different parsers.
The parse will try each parse pattern in turn.
From source file:org.ejbca.util.ValidityDate.java
/** Parse a String in the format "yyyy-MM-dd HH:mm:ssZZ". */ public static Date parseAsIso8601(final String dateString) throws ParseException { return DateUtils.parseDateStrictly(dateString, ISO8601_PATTERNS); }
From source file:org.kuali.mobility.events.service.EventsServiceImpl.java
@GET @Path("/findByDateRange") public List<EventImpl> getEventsByDateRange(@QueryParam(value = "campus") String campus, @QueryParam(value = "fromDate") String fromDate, @QueryParam(value = "toDate") String toDate, @QueryParam(value = "categoryId") String categoryId) { Date startDate, endDate;// w ww. j a v a 2 s .c om List<EventImpl> events = new ArrayList<EventImpl>(); try { startDate = DateUtils.parseDateStrictly(fromDate, DATE_PATTERNS); endDate = DateUtils.parseDateStrictly(toDate, DATE_PATTERNS); } catch (ParseException pe) { LOG.error(pe.getLocalizedMessage(), pe); startDate = new Date(); endDate = new Date(); } if (null == categoryId || categoryId.isEmpty()) { events = getEventsForDateRange(fromDate, toDate); } else { events = getAllEventsByDateFromTo(campus, categoryId, startDate, endDate); } return events; }
From source file:TDS.Proctor.Sql.Repository.TesteeRepository.java
private Date parseBirthday(String value) throws SQLException { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(0);//www . ja v a2s. c o m if (StringUtils.isEmpty(value)) { return DateTime.getMinValue(); } Date birthday; try { // parse other date formats 1. 2008-05-01 2. 01 Nov 2008 3. 03/01/2009 birthday = DateUtils.parseDateStrictly(value, new String[] { "MMddyyyy", "yyyy-MM-dd", "dd MMM yyyy ", "MM/dd/yyyy" }); } catch (Exception e) { birthday = DateTime.getMinValue(); // keep the birthday as is from RTS } return birthday; }
From source file:TDS.Proctor.Sql.RepositorySP.TesteeRepository.java
private Date parseBirthday(String value) throws SQLException { if (StringUtils.isEmpty(value)) { return DateTime.getMinValue(); }// w w w . j a v a2s . c o m Date birthday; try { // parse other date formats 1. 2008-05-01 2. 01 Nov 2008 3. 03/01/2009 birthday = DateUtils.parseDateStrictly(value, new String[] { "MMddyyyy", "yyyy-MM-dd", "dd MMM yyyy ", "MM/dd/yyyy" }); } catch (Exception e) { birthday = DateTime.getMinValue(); // keep the birthday as is from RTS } return birthday; }