com.fasterxml.jackson.databind.util.ISO8601Utils#parse ( )源码实例Demo

下面列出了com.fasterxml.jackson.databind.util.ISO8601Utils#parse ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ameba   文件: ParamConverters.java
/**
 * <p>parseDate.</p>
 *
 * @param value a {@link java.lang.String} object.
 * @param pos   a {@link java.text.ParsePosition} object.
 * @return a {@link java.util.Date} object.
 */
public static Date parseDate(String value, ParsePosition pos) {
    Long timestamp = parseTimestamp(value);
    if (timestamp != null) {
        return new Date(timestamp);
    }
    if (value.contains(" ")) {
        value = value.replace(" ", "+");
    }
    if (!(value.contains("-") || value.contains("+")) && !value.endsWith("Z")) {
        value += SYS_TZ;
    }
    try {
        return ISO8601Utils.parse(value, pos);
    } catch (ParseException e) {
        throw new ExtractorException(e);
    }
}
 
/**
 * <p>
 * Parses the ISO-8601 date from the image JSON.
 * </p>
 * <p>
 * Handles the bug in the NASA JSON where not all timestamps comply with ISO-8601 (some are missing the 'Z' for UTC
 * time at the end of the timestamp).
 * </p>
 * Uses Jackson ISO8601Utils to convert the timestamp.
 *
 * @param image
 *            JSON representation of the image
 * @return Java Date object containing the creation time stamp
 */
protected static Date getTimestamp(final JsonNode image) {
    Date date = null;
    String iso8601 = image.get(IMAGE_TIME_KEY).get(CREATION_TIME_STAMP_KEY).asText();
    try {
        date = ISO8601Utils.parse(iso8601);
    } catch (final IllegalArgumentException e) {
        // Don't like this, but not all times have the Z at the end for
        // ISO-8601
        if (iso8601.charAt(iso8601.length() - 1) != 'Z') {
            iso8601 = iso8601 + "Z";
            date = ISO8601Utils.parse(iso8601);
        } else {
            throw e;
        }
    }
    return date;
}
 
private void handleDueBefore(TaskInfoQueryWrapper taskInfoQueryWrapper, JsonNode dueBeforeNode) {
  String date = dueBeforeNode.asText();
  Date d = null;
  try {
    d = ISO8601Utils.parse(date, new ParsePosition(0));
  } catch (ParseException e) {
    e.printStackTrace();
  }
  taskInfoQueryWrapper.getTaskInfoQuery().taskDueBefore(d);
}
 
private void handleDueAfter(TaskInfoQueryWrapper taskInfoQueryWrapper, JsonNode dueAfterNode) {
  String date = dueAfterNode.asText();
  Date d = null;
  try {
    d = ISO8601Utils.parse(date, new ParsePosition(0));
  } catch (ParseException e) {
    e.printStackTrace();
  }
  taskInfoQueryWrapper.getTaskInfoQuery().taskDueAfter(d);
}
 
源代码5 项目: emodb   文件: JsonHelper.java
/** Parses an ISO 8601 date+time string into a Java Date object. */
public static Date parseTimestamp(@Nullable String string) {
    Date date = null;
    try {
        if (string != null) {
            date = ISO8601Utils.parse(string, new ParsePosition(0));
        }
    } catch (ParseException e) {
        throw Throwables.propagate(e);
    }
    return date;
}
 
源代码6 项目: flowable-engine   文件: AsyncHistoryDateUtil.java
public static Date parseDate(String s) {
    if (s != null) {
        try {
            return ISO8601Utils.parse(s, new ParsePosition(0));
        } catch (ParseException e) {
            return null;
        }
    }
    return null;
}
 
源代码7 项目: apiman   文件: JdbcMetricsTest.java
/**
 * @throws ParseException 
 */
private RequestMetric request(String requestStart, long requestDuration, String url, String resource,
        String method, String apiOrgId, String apiId, String apiVersion, String planId,
        String clientOrgId, String clientId, String clientVersion, String contractId, String user,
        int responseCode, String responseMessage, boolean failure, int failureCode, String failureReason,
        boolean error, String errorMessage, long bytesUploaded, long bytesDownloaded) throws ParseException {
    Date start = ISO8601Utils.parse(requestStart, new ParsePosition(0));
    RequestMetric rval = new RequestMetric();
    rval.setRequestStart(start);
    rval.setRequestEnd(new Date(start.getTime() + requestDuration));
    rval.setApiStart(start);
    rval.setApiEnd(rval.getRequestEnd());
    rval.setApiDuration(requestDuration);
    rval.setUrl(url);
    rval.setResource(resource);
    rval.setMethod(method);
    rval.setApiOrgId(apiOrgId);
    rval.setApiId(apiId);
    rval.setApiVersion(apiVersion);
    rval.setPlanId(planId);
    rval.setClientOrgId(clientOrgId);
    rval.setClientId(clientId);
    rval.setClientVersion(clientVersion);
    rval.setContractId(contractId);
    rval.setUser(user);
    rval.setResponseCode(responseCode);
    rval.setResponseMessage(responseMessage);
    rval.setFailure(failure);
    rval.setFailureCode(failureCode);
    rval.setFailureReason(failureReason);
    rval.setError(error);
    rval.setErrorMessage(errorMessage);
    rval.setBytesUploaded(bytesUploaded);
    rval.setBytesDownloaded(bytesDownloaded);
    return rval;
}