List of usage examples for org.apache.http.client.utils DateUtils parseDate
public static Date parseDate(final String dateValue, final String[] dateFormats)
From source file:com.oneops.controller.jms.InductorListener.java
/** * Set the time stamps in the wo/ao for search/analytics * //from ww w . j a v a 2 s . c o m * @param wo */ private void setWoTimeStamps(CmsWorkOrderSimpleBase wo) { String responseDequeTs = DateUtils.formatDate(new Date(), CmsConstants.SEARCH_TS_PATTERN); wo.getSearchTags().put(CmsConstants.RESPONSE_DEQUE_TS, responseDequeTs); String closeTime, totalTime; try { closeTime = String.valueOf( (DateUtils.parseDate(responseDequeTs, new String[] { CmsConstants.SEARCH_TS_PATTERN }).getTime() - DateUtils.parseDate(wo.getSearchTags().get(CmsConstants.RESPONSE_ENQUE_TS), new String[] { CmsConstants.SEARCH_TS_PATTERN }).getTime()) / 1000.0); wo.getSearchTags().put(CmsConstants.CLOSE_TIME, closeTime); totalTime = String.valueOf( (DateUtils.parseDate(responseDequeTs, new String[] { CmsConstants.SEARCH_TS_PATTERN }).getTime() - DateUtils.parseDate(wo.getSearchTags().get(CmsConstants.REQUEST_ENQUE_TS), new String[] { CmsConstants.SEARCH_TS_PATTERN }).getTime()) / 1000.0); wo.getSearchTags().put(CmsConstants.TOTAL_TIME, totalTime); } catch (Exception e) { logger.error("Exception occured while parsing date " + e); } }
From source file:com.joyent.manta.client.MantaObjectResponse.java
@Override public Date getLastModifiedTime() { final String lastModified; if (getMtime() != null) { lastModified = getMtime();/* www .ja v a2 s .c o m*/ } else if (getHttpHeaders() != null && getHttpHeaders().getLastModified() != null) { lastModified = getHttpHeaders().getLastModified(); } else { return null; } final Date parsed = DateUtils.parseDate(lastModified, DATETIME_FORMATS); if (parsed == null) { LOGGER.warn("Error parsing mtime value [{}] with formats: {}", lastModified, DATETIME_FORMATS); } return parsed; }