@Test public void testContextualTimestampList() { String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss"; String[] dates = new String[]{ "2000-01-01T05:00:00", "2000-01-01T05:00:01", "2000-01-01T05:00:01", "2000-01-01T05:00:02", "2000-01-01T05:00:03", }; TimestampSpec spec = new TimestampSpec("TIMEstamp", DATE_FORMAT, null); DateTimes.UtcFormatter formatter = DateTimes.wrapFormatter(ISODateTimeFormat.dateHourMinuteSecond()); for (String date : dates) { DateTime dateTime = spec.extractTimestamp(ImmutableMap.of("TIMEstamp", date)); DateTime expectedDateTime = formatter.parse(date); Assert.assertEquals(expectedDateTime, dateTime); } } }
formatter = ISODateTimeFormat.dateHourMinute(); } else if ("dateHourMinuteSecond".equals(input) || "date_hour_minute_second".equals(input)) { formatter = ISODateTimeFormat.dateHourMinuteSecond(); } else if ("dateHourMinuteSecondFraction".equals(input) || "date_hour_minute_second_fraction".equals(input)) { formatter = ISODateTimeFormat.dateHourMinuteSecondFraction();
formatter = ISODateTimeFormat.dateHourMinute(); } else if ("dateHourMinuteSecond".equals(input) || "date_hour_minute_second".equals(input)) { formatter = ISODateTimeFormat.dateHourMinuteSecond(); } else if ("dateHourMinuteSecondFraction".equals(input) || "date_hour_minute_second_fraction".equals(input)) { formatter = ISODateTimeFormat.dateHourMinuteSecondFraction();
default String printDate(DateTime dateTime) { return ISODateTimeFormat.dateHourMinuteSecond().print(dateTime); } }
formatter = ISODateTimeFormat.dateHourMinute(); } else if ("dateHourMinuteSecond".equals(input) || "date_hour_minute_second".equals(input)) { formatter = ISODateTimeFormat.dateHourMinuteSecond(); } else if ("dateHourMinuteSecondFraction".equals(input) || "date_hour_minute_second_fraction".equals(input)) { formatter = ISODateTimeFormat.dateHourMinuteSecondFraction();
/** * Returns string representation of this date time. The string representation * does not include the time zone since using date times for filtering * does not use the time zone. If you need to convert the date time * into another time zone before filtering on it, please use * {@link #toStringForTimeZone(Object, String)} instead. * * @param dateTime the date time to stringify * @return a string representation of the {@code DateTime} in * {@code yyyy-MM-dd'T'HH:mm:ss} */ public String toString(T dateTime) { return toDateTime(dateTime).toString(ISODateTimeFormat.dateHourMinuteSecond()); }
formatter = ISODateTimeFormat.dateHourMinute(); } else if ("dateHourMinuteSecond".equals(input) || "date_hour_minute_second".equals(input)) { formatter = ISODateTimeFormat.dateHourMinuteSecond(); } else if ("dateHourMinuteSecondFraction".equals(input) || "date_hour_minute_second_fraction".equals(input)) { formatter = ISODateTimeFormat.dateHourMinuteSecondFraction();
/** * Returns string representation of this date time. The string representation * does not include the time zone since using date times for filtering * does not use the time zone. If you need to convert the date time * into another time zone before filtering on it, please use * {@link #toStringForTimeZone(Object, String)} instead. * * @param dateTime the date time to stringify * @return a string representation of the {@code DateTime} in * {@code yyyy-MM-dd'T'HH:mm:ss} */ public String toString(T dateTime) { return toDateTime(dateTime).toString(ISODateTimeFormat.dateHourMinuteSecond()); }
formatter = ISODateTimeFormat.dateHourMinute(); } else if ("dateHourMinuteSecond".equals(input) || "date_hour_minute_second".equals(input)) { formatter = ISODateTimeFormat.dateHourMinuteSecond(); } else if ("dateHourMinuteSecondFraction".equals(input) || "date_hour_minute_second_fraction".equals(input)) { formatter = ISODateTimeFormat.dateHourMinuteSecondFraction();
/** * Converts a string in the form of {@code yyyy-MM-dd'T'HH:mm:ss} to an API * date time in the time zone supplied. */ public T toDateTime(String dateTime, String timeZoneId) { return toDateTime(ISODateTimeFormat.dateHourMinuteSecond().parseDateTime(dateTime) .withZoneRetainFields(DateTimeZone.forTimeZone(TimeZone.getTimeZone(timeZoneId)))); }
formatter = ISODateTimeFormat.dateHourMinute(); } else if ("dateHourMinuteSecond".equals(input) || "date_hour_minute_second".equals(input)) { formatter = ISODateTimeFormat.dateHourMinuteSecond(); } else if ("dateHourMinuteSecondFraction".equals(input) || "date_hour_minute_second_fraction".equals(input)) { formatter = ISODateTimeFormat.dateHourMinuteSecondFraction();
/** * Converts a string in the form of {@code yyyy-MM-dd'T'HH:mm:ss} to an API * date time in the time zone supplied. */ public T toDateTime(String dateTime, String timeZoneId) { return toDateTime(ISODateTimeFormat.dateHourMinuteSecond().parseDateTime(dateTime) .withZoneRetainFields(DateTimeZone.forTimeZone(TimeZone.getTimeZone(timeZoneId)))); }
return new FormatterAndType(ISODateTimeFormat.dateHourMinuteSecond(), ElasticMappingSet.Type.TIMESTAMP);
public NotificationModel(Notification notification) { this.message = notification.message; this.type = notification.type.name().toLowerCase(); this.id = notification.getId(); this.repeated = notification.repeated; this.time = ISODateTimeFormat.dateHourMinuteSecond().withZoneUTC().print(notification.ts)+"Z"; }
/** * Returns string representation of this date time with a different time * zone, preserving the millisecond instant. * <p>This method is useful for finding the local time in another time zone, * especially for filtering. * <p>For example, if this date time holds 12:30 in Europe/London, the result * from this method with Europe/Paris would be 13:30. You may also want to use * this with your network's time zone, i.e. * <pre><code> String timeZoneId = networkService.getCurrentNetwork().getTimeZone(); * String statementPart = * "startDateTime > " * + DateTimes.toString(apiDateTime, timeZoneId); * //... * statementBuilder.where(statementPart); * </code></pre> * This method is in the same style of * {@link DateTime#withZone(org.joda.time.DateTimeZone)}. * * @param dateTime the date time to stringify into a new time zone * @param newZoneID the time zone ID of the new zone * @return a string representation of the {@code DateTime} in * {@code yyyy-MM-dd'T'HH:mm:ss} */ public String toStringForTimeZone(T dateTime, String newZoneID) { return toDateTime(dateTime) .withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone(newZoneID))) .toString(ISODateTimeFormat.dateHourMinuteSecond()); } }
/** * Returns string representation of this date time with a different time * zone, preserving the millisecond instant. * <p>This method is useful for finding the local time in another time zone, * especially for filtering. * <p>For example, if this date time holds 12:30 in Europe/London, the result * from this method with Europe/Paris would be 13:30. You may also want to use * this with your network's time zone, i.e. * <pre><code> String timeZoneId = networkService.getCurrentNetwork().getTimeZone(); * String statementPart = * "startDateTime > " * + DateTimes.toString(apiDateTime, timeZoneId); * //... * statementBuilder.where(statementPart); * </code></pre> * This method is in the same style of * {@link DateTime#withZone(org.joda.time.DateTimeZone)}. * * @param dateTime the date time to stringify into a new time zone * @param newZoneID the time zone ID of the new zone * @return a string representation of the {@code DateTime} in * {@code yyyy-MM-dd'T'HH:mm:ss} */ public String toStringForTimeZone(T dateTime, String newZoneID) { return toDateTime(dateTime) .withZone(DateTimeZone.forTimeZone(TimeZone.getTimeZone(newZoneID))) .toString(ISODateTimeFormat.dateHourMinuteSecond()); } }
ISODateTimeFormat.dateHourMinuteSecond().print(value), /*does not include timezone*/ XSDDatatype.XSDdateTime);
timeBlockMap.put("startDate", start.toString(HrConstants.DateTimeFormats.BASIC_DATE_FORMAT)); timeBlockMap.put("endDate", end.toString(HrConstants.DateTimeFormats.BASIC_DATE_FORMAT)); timeBlockMap.put("startNoTz", start.toString(ISODateTimeFormat.dateHourMinuteSecond())); timeBlockMap.put("endNoTz", end.toString(ISODateTimeFormat.dateHourMinuteSecond()));
.appendFractionOfSecond(3, 3).toFormatter(); DateTimeFormatter dhmsFormatter = ISODateTimeFormat.dateHourMinuteSecond();