/** * Override the default header timestamp format for input type because we have always marshalled header value as ISO_8601, changing it to * rfc822 might break existing customers who are relying on that behavior. If not configured, we set it to UNKNOWN and let HeaderMarshallers.DATE * to set the default format. */ @Override protected String defaultHeaderTimestamp() { return TimestampFormat.UNKNOWN.getFormat(); }
protected String defaultHeaderTimestamp() { return TimestampFormat.RFC_822.getFormat(); }
@Override public Date unmarshall(StaxUnmarshallerContext unmarshallerContext) throws Exception { String dateString = unmarshallerContext.readText(); if (dateString == null) return null; try { if (TimestampFormat.RFC_822.getFormat().equals(dateFormatType)) { return DateUtils.parseRFC822Date(dateString); } if (TimestampFormat.UNIX_TIMESTAMP.getFormat().equals(dateFormatType)) { return DateUtils.parseServiceSpecificDate(dateString); } return DateUtils.parseISO8601Date(dateString); } catch (Exception e) { log.warn("Unable to parse date '" + dateString + "': " + e.getMessage(), e); return null; } }
@Override public Date unmarshall(JsonUnmarshallerContext unmarshallerContext) throws Exception { String dateString = unmarshallerContext.readText(); if (dateString == null) { return null; } try { if (TimestampFormat.RFC_822.getFormat().equals(dateFormatType)) { return DateUtils.parseRFC822Date(dateString); } if (TimestampFormat.UNIX_TIMESTAMP.getFormat().equals(dateFormatType)) { return DateUtils.parseServiceSpecificDate(dateString); } if (TimestampFormat.UNIX_TIMESTAMP_IN_MILLIS.getFormat().equals(dateFormatType)) { return DateUtils.parseUnixTimestampInMillis(dateString); } return DateUtils.parseISO8601Date(dateString); } catch (Exception exception) { // fallback to the original behavior. return DateJsonUnmarshaller.getInstance().unmarshall(unmarshallerContext); } }
return TimestampFormat.fromValue(timestampFormat).getFormat(); return TimestampFormat.fromValue(shape.getTimestampFormat()).getFormat(); return TimestampFormat.ISO_8601.getFormat(); case EC2: case API_GATEWAY: return TimestampFormat.ISO_8601.getFormat(); case ION: case REST_JSON: case AWS_JSON: return TimestampFormat.UNIX_TIMESTAMP.getFormat(); case CBOR: return TimestampFormat.UNIX_TIMESTAMP_IN_MILLIS.getFormat();
@Override public void marshall(Date val, JsonMarshallerContext context, MarshallingInfo<Date> marshallingInfo) { TimestampFormat timestampFormat = marshallingInfo.timestampFormat(); context.request().addParameter(marshallingInfo.marshallLocationName(), StringUtils.fromDate(val, timestampFormat.getFormat())); } };
@Override public void marshall(Date val, JsonMarshallerContext context, MarshallingInfo<Date> marshallingInfo) { TimestampFormat timestampFormat = marshallingInfo.timestampFormat(); if (TimestampFormat.UNKNOWN.equals(timestampFormat)) { timestampFormat = TimestampFormat.ISO_8601; } context.request().addHeader(marshallingInfo.marshallLocationName(), StringUtils.fromDate(val, timestampFormat.getFormat())); } };
@Override public Date unmarshall(StaxUnmarshallerContext unmarshallerContext) throws Exception { String dateString = unmarshallerContext.readText(); if (dateString == null) return null; try { if (TimestampFormat.RFC_822.getFormat().equals(dateFormatType)) { return DateUtils.parseRFC822Date(dateString); } if (TimestampFormat.UNIX_TIMESTAMP.getFormat().equals(dateFormatType)) { return DateUtils.parseServiceSpecificDate(dateString); } return DateUtils.parseISO8601Date(dateString); } catch (Exception e) { log.warn("Unable to parse date '" + dateString + "': " + e.getMessage(), e); return null; } }
@Override public Date unmarshall(JsonUnmarshallerContext unmarshallerContext) throws Exception { String dateString = unmarshallerContext.readText(); if (dateString == null) { return null; } try { if (TimestampFormat.RFC_822.getFormat().equals(dateFormatType)) { return DateUtils.parseRFC822Date(dateString); } if (TimestampFormat.UNIX_TIMESTAMP.getFormat().equals(dateFormatType)) { return DateUtils.parseServiceSpecificDate(dateString); } if (TimestampFormat.UNIX_TIMESTAMP_IN_MILLIS.getFormat().equals(dateFormatType)) { return DateUtils.parseUnixTimestampInMillis(dateString); } return DateUtils.parseISO8601Date(dateString); } catch (Exception exception) { // fallback to the original behavior. return DateJsonUnmarshaller.getInstance().unmarshall(unmarshallerContext); } }
@Override public void marshall(Date val, JsonMarshallerContext context, MarshallingInfo<Date> marshallingInfo) { TimestampFormat timestampFormat = marshallingInfo.timestampFormat(); context.request().addParameter(marshallingInfo.marshallLocationName(), StringUtils.fromDate(val, timestampFormat.getFormat())); } };
@Override public void marshall(Date val, JsonMarshallerContext context, MarshallingInfo<Date> marshallingInfo) { TimestampFormat timestampFormat = marshallingInfo.timestampFormat(); if (TimestampFormat.UNKNOWN.equals(timestampFormat)) { timestampFormat = TimestampFormat.ISO_8601; } context.request().addHeader(marshallingInfo.marshallLocationName(), StringUtils.fromDate(val, timestampFormat.getFormat())); } };
/** * Override the default header timestamp format for input type because we have always marshalled header value as ISO_8601, changing it to * rfc822 might break existing customers who are relying on that behavior. If not configured, we set it to UNKNOWN and let HeaderMarshallers.DATE * to set the default format. */ @Override protected String defaultHeaderTimestamp() { return TimestampFormat.UNKNOWN.getFormat(); }
protected String defaultHeaderTimestamp() { return TimestampFormat.RFC_822.getFormat(); }
return TimestampFormat.fromValue(timestampFormat).getFormat(); return TimestampFormat.fromValue(shape.getTimestampFormat()).getFormat(); return TimestampFormat.ISO_8601.getFormat(); case EC2: case API_GATEWAY: return TimestampFormat.ISO_8601.getFormat(); case ION: case REST_JSON: case AWS_JSON: return TimestampFormat.UNIX_TIMESTAMP.getFormat(); case CBOR: return TimestampFormat.UNIX_TIMESTAMP_IN_MILLIS.getFormat();