/** * Converts the specified date to an ISO 8601 timestamp string and returns * it. * * @param value * The date to format as an ISO 8601 timestamp string. * * @return An ISO 8601 timestamp string created from the specified date. */ public static String fromDate(Date value) { return DateUtils.formatISO8601Date(value); }
@Override public final String convert(final Date o) { return DateUtils.formatISO8601Date(o); } };
public static String formatIso8601Date(Date date) { return DateUtils.formatISO8601Date(date); }
@Override public void serialize( DateTime value, JsonGenerator jgen, SerializerProvider provider) throws IOException { jgen.writeString(DateUtils.formatISO8601Date(value)); } }
@Override public AttributeValue marshall(Object obj) { @SuppressWarnings("unchecked") Set<Calendar> dates = (Set<Calendar>) obj; List<String> timestamps = new ArrayList<String>(dates.size()); for (Calendar date : dates) { timestamps.add(DateUtils.formatISO8601Date(date.getTime())); } return new AttributeValue().withSS(timestamps); } }
/** * Constructs a new access policy condition that compares the current time * (on the AWS servers) to the specified date. * * @param type * The type of comparison to perform. For example, * {@link DateComparisonType#DateLessThan} will cause this policy * condition to evaluate to true if the current date is less than * the date specified in the second argument. * @param date * The date to compare against. */ public DateCondition(DateComparisonType type, Date date) { super.type = type.toString(); super.conditionKey = ConditionFactory.CURRENT_TIME_CONDITION_KEY; super.values = Arrays.asList(new String[] {DateUtils.formatISO8601Date(date)}); }
@Override public AttributeValue marshall(Object obj) { @SuppressWarnings("unchecked") Set<Date> dates = (Set<Date>) obj; List<String> timestamps = new ArrayList<String>(dates.size()); for (Date date : dates) { timestamps.add(DateUtils.formatISO8601Date(date)); } return new AttributeValue().withSS(timestamps); } }
@Override public AttributeValue marshall(Object obj) { return new AttributeValue().withS( DateUtils.formatISO8601Date(((Calendar) obj).getTime())); } }
public static String fromDate(Date date, String timestampFormat) { if ("unixTimestamp".equalsIgnoreCase(timestampFormat)) { return DateUtils.formatServiceSpecificDate(date); } if ("iso8601".equalsIgnoreCase(timestampFormat)) { return DateUtils.formatISO8601Date(date); } if ("rfc822".equalsIgnoreCase(timestampFormat)) { return DateUtils.formatRFC822Date(date); } if ("unixTimestampInMillis".equalsIgnoreCase(timestampFormat)) { return DateUtils.formatUnixTimestampInMills(date); } throw new IllegalArgumentException("unsupported timestamp format"); }
@Override public AttributeValue marshall(Object obj) { return new AttributeValue().withS( DateUtils.formatISO8601Date((Date) obj)); } }
@Override public StructuredJsonGenerator writeValue(Date date, TimestampFormat timestampFormat) { try { switch (timestampFormat) { case UNIX_TIMESTAMP_IN_MILLIS: generator.writeNumber(DateUtils.formatUnixTimestampInMills(date)); break; case ISO_8601: generator.writeString(DateUtils.formatISO8601Date(date)); break; case RFC_822: generator.writeString(DateUtils.formatRFC822Date(date)); break; case UNIX_TIMESTAMP: default: generator.writeNumber(DateUtils.formatServiceSpecificDate(date)); } } catch (IOException e) { throw new JsonGenerationException(e); } return this; }
/** * Converts the specified date to an ISO 8601 timestamp string and returns * it. * * @param value * The date to format as an ISO 8601 timestamp string. * * @return An ISO 8601 timestamp string created from the specified date. */ public static String fromDate(Date value) { return DateUtils.formatISO8601Date(value); }
/** * Formats an instance of Date to ISO-8601. * @param date Date * @return date in ISO-8601 format. */ public static String formatIso8601Date(Date date) { return DateUtils.formatISO8601Date(date); }
/** * Converts the specified date to an ISO 8601 timestamp string and returns * it. * * @param value The date to format as an ISO 8601 timestamp string. * @return An ISO 8601 timestamp string created from the specified date. */ public static String fromDate(Date value) { return DateUtils.formatISO8601Date(value); }
public <T> ProtocolRequestMarshaller<T> createProtocolMarshaller(OperationInfo operationInfo, T origRequest) { return JsonProtocolMarshallerBuilder.<T>standard() .jsonGenerator(operationInfo.hasPayloadMembers() ? createGenerator() : StructuredJsonGenerator.NO_OP) .contentType(getContentType()) .operationInfo(operationInfo) .originalRequest(origRequest) .sendExplicitNullForPayload(true) .marshallerOverride(MarshallLocation.PAYLOAD, MarshallingType.DATE, (val, generator) -> generator.writeValue(DateUtils.formatISO8601Date(val))) .build(); }
@Override public void serialize( DateTime value, JsonGenerator jgen, SerializerProvider provider) throws IOException { jgen.writeString(DateUtils.formatISO8601Date(value)); } }
@Override public AttributeValue marshall(Object obj) { @SuppressWarnings("unchecked") final Set<Date> dates = (Set<Date>) obj; final List<String> timestamps = new ArrayList<String>(dates.size()); for (final Date date : dates) { timestamps.add(DateUtils.formatISO8601Date(date)); } return new AttributeValue().withSS(timestamps); } }
@Override public AttributeValue marshall(Object obj) { return new AttributeValue().withS( DateUtils.formatISO8601Date((Date) obj)); } }
@Test public void testIso8601Date() { Date date = new Date(); String expected = iso8601DateFormat.print(date.getTime()); String actual = DateUtils.formatISO8601Date(date); assertEquals(expected, actual); Date expectedDate = new Date(iso8601DateFormat.parseMillis(expected)); Date actualDate = DateUtils.parseISO8601Date(actual); assertEquals(expectedDate, actualDate); }
@Test public void testDateStaxUnmarshaller() throws Exception { Date data = new Date(1000); SimpleTypeStaxUnmarshallers.DateStaxUnmarshaller unmarshaller = SimpleTypeStaxUnmarshallers.DateStaxUnmarshaller .getInstance(); Date unmarshalled = unmarshaller.unmarshall(getContext(DateUtils.formatISO8601Date(data))); assertEquals(unmarshalled.getTime(), data.getTime()); }