/** * Sets this {@link EntityProperty} using the serialized <code>java.util.Date</code> value. * * @param value * The <code>java.util.Date</code> value to set as the {@link EntityProperty} value. This value may be * <code>null</code>. */ public synchronized final void setValue(final Date value) { this.edmType = EdmType.DATE_TIME; this.type = Date.class; this.value = value == null ? null : Utility.getJavaISO8601Time(value); }
/** * Sets this {@link EntityProperty} using the serialized <code>java.util.Date</code> value. * * @param value * The <code>java.util.Date</code> value to set as the {@link EntityProperty} value. This value may be * <code>null</code>. */ public synchronized final void setValue(final Date value) { this.edmType = EdmType.DATE_TIME; this.type = Date.class; this.value = value == null ? null : Utility.getJavaISO8601Time(value); }
/** * Generates a property filter condition string for a <code>java.util.Date</code> value. Creates a formatted string to use in * a filter expression that uses the specified operation to compare the property with the value, formatted as a * datetime value, as in the following example: * <p> * <code>String condition = generateFilterCondition("FutureDate", QueryComparisons.GREATER_THAN, new Date());</code> * <p> * This statement sets <code>condition</code> to something like the following value: * <p> * <code>FutureDate gt datetime'2013-01-31T09:00:00'</code> * * @param propertyName * A <code>String</code> which specifies the name of the property to compare. * @param operation * A <code>String</code> which specifies the comparison operator to use. * @param value * A <code>java.util.Date</code> which specifies the value to compare with the property. * @return * A <code>String</code> which represents the formatted filter condition. */ public static String generateFilterCondition(String propertyName, String operation, final Date value) { return generateFilterCondition(propertyName, operation, Utility.getJavaISO8601Time(value), EdmType.DATE_TIME); }
/** * Generates a property filter condition string for a <code>java.util.Date</code> value. Creates a formatted string to use in * a filter expression that uses the specified operation to compare the property with the value, formatted as a * datetime value, as in the following example: * <p> * <code>String condition = generateFilterCondition("FutureDate", QueryComparisons.GREATER_THAN, new Date());</code> * <p> * This statement sets <code>condition</code> to something like the following value: * <p> * <code>FutureDate gt datetime'2013-01-31T09:00:00'</code> * * @param propertyName * A <code>String</code> which specifies the name of the property to compare. * @param operation * A <code>String</code> which specifies the comparison operator to use. * @param value * A <code>java.util.Date</code> which specifies the value to compare with the property. * @return * A <code>String</code> which represents the formatted filter condition. */ public static String generateFilterCondition(String propertyName, String operation, final Date value) { return generateFilterCondition(propertyName, operation, Utility.getJavaISO8601Time(value), EdmType.DATE_TIME); }
generator.writeStringField(TableConstants.TIMESTAMP, Utility.getJavaISO8601Time(entity.getTimestamp()));
generator.writeStringField(TableConstants.TIMESTAMP, Utility.getJavaISO8601Time(entity.getTimestamp()));
@Test public void testDateStringFormatting() { String fullDateString = "2014-12-07T09:15:12.123Z"; String outDateString = Utility.getJavaISO8601Time(Utility.parseDate(fullDateString)); assertEquals(fullDateString, outDateString); fullDateString = "2015-01-14T14:53:32.800Z"; outDateString = Utility.getJavaISO8601Time(Utility.parseDate(fullDateString)); assertEquals(fullDateString, outDateString); // Ensure that trimming of trailing zeroes by the service does not affect this fullDateString = "2015-01-14T14:53:32.8Z"; outDateString = Utility.getJavaISO8601Time(Utility.parseDate(fullDateString)); fullDateString = fullDateString.replace("Z", "00Z"); assertEquals(fullDateString, outDateString); // Ensure that trimming of trailing zeroes by the service does not affect this // even with dateBackwardCompatibility fullDateString = "2015-01-14T14:53:32.0000800Z"; outDateString = Utility.getJavaISO8601Time(Utility.parseDate(fullDateString, true)); fullDateString = "2015-01-14T14:53:32.800Z"; assertEquals(fullDateString, outDateString); }