/** * Returns a formatter that can be use by the current thread if needed to * convert Date objects to the Internal representation. * @throws ParseException * @throws DateParseException * * @deprecated Use {@link org.apache.solr.common.util.DateUtil#parseDate(String)} */ public static Date parseDate( String d ) throws ParseException, DateParseException { return DateUtil.parseDate(d); }
/** * Returns a formatter that can be use by the current thread if needed to * convert Date objects to the Internal representation. * * @param d The input date to parse * @return The parsed {@link java.util.Date} * @throws java.text.ParseException If the input can't be parsed */ public static Date parseDate(String d) throws ParseException { return parseDate(d, DEFAULT_DATE_FORMATS); }
@Override public Date read( String txt ) { try { return DateUtil.parseDate(txt); } catch( Exception ex ) { ex.printStackTrace(); } return null; } },
public static Date parseDate(String d, Collection<String> fmts) throws ParseException { // 2007-04-26T08:05:04Z if (d.endsWith("Z") && d.length() > 20) { return getThreadLocalDateFormat().parse(d); } return parseDate(d, fmts, null); }
/** Parse a date string in the standard format, or any supported by DateUtil.parseDate */ public Date parseDateLenient(String s, SolrQueryRequest req) throws ParseException { // request could define timezone in the future try { return fmtThreadLocal.get().parse(s); } catch (Exception e) { return DateUtil.parseDate(s); } }
/** * @see org.opencms.search.I_CmsSearchDocument#getFieldValueAsDate(java.lang.String) */ public Date getFieldValueAsDate(String fieldName) { Object o = m_doc.getFieldValue(fieldName); if (o instanceof Date) { return (Date)o; } if (o != null) { try { return DateUtil.parseDate(o.toString()); } catch (ParseException e) { // ignore: not a valid date format LOG.debug(e); } } return null; }
/** * Can be used to transform input values based on their {@link org.apache.solr.schema.SchemaField} * <p/> * This implementation only formats dates using the {@link org.apache.solr.common.util.DateUtil}. * * @param val The value to transform * @param schFld The {@link org.apache.solr.schema.SchemaField} * @return The potentially new value. */ protected String transformValue(String val, SchemaField schFld) { String result = val; if (schFld != null && schFld.getType() instanceof DateField) { //try to transform the date try { Date date = DateUtil.parseDate(val, dateFormats); DateFormat df = DateUtil.getThreadLocalDateFormat(); result = df.format(date); } catch (Exception e) { // Let the specific fieldType handle errors // throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Invalid value: " + val + " for field: " + schFld, e); } } return result; }
Header lastUpdateDate = response.getFirstHeader(LAST_MODIFIED_HEADER); if (lastUpdateDate != null) { return DateUtil.parseDate(lastUpdateDate.getValue()).getTime();