/** * Constructs a YearMonthDay from an Object that represents a time. * <p> * The recognised object types are defined in * {@link org.joda.time.convert.ConverterManager ConverterManager} and * include ReadableInstant, String, Calendar and Date. * The String formats are described by {@link ISODateTimeFormat#dateOptionalTimeParser()}. * <p> * The chronology used will be derived from the object, defaulting to ISO. * <p> * NOTE: Prior to v1.3 the string format was described by * {@link ISODateTimeFormat#dateTimeParser()}. Time only strings are now rejected. * * @param instant the datetime object, null means now * @throws IllegalArgumentException if the instant is invalid */ public YearMonthDay(Object instant) { super(instant, null, ISODateTimeFormat.dateOptionalTimeParser()); }
/** * Constructs a YearMonthDay from an Object that represents a time. * <p> * The recognised object types are defined in * {@link org.joda.time.convert.ConverterManager ConverterManager} and * include ReadableInstant, String, Calendar and Date. * The String formats are described by {@link ISODateTimeFormat#dateOptionalTimeParser()}. * <p> * The chronology used will be derived from the object, defaulting to ISO. * <p> * NOTE: Prior to v1.3 the string format was described by * {@link ISODateTimeFormat#dateTimeParser()}. Time only strings are now rejected. * * @param instant the datetime object, null means now * @throws IllegalArgumentException if the instant is invalid */ public YearMonthDay(Object instant) { super(instant, null, ISODateTimeFormat.dateOptionalTimeParser()); }
static Object convertFromES(String esDate) { return ISODateTimeFormat.dateOptionalTimeParser().parseDateTime(esDate); }
public static Date parseDate(Object d, Date dflt) { if (d == null) return dflt; if (d instanceof Long) return new Date(((Long) d).longValue()); if (d instanceof String) return ISODateTimeFormat.dateOptionalTimeParser().parseDateTime((String) d).toDate(); if (d instanceof Date) return (Date) d; assert false; return dflt; }
public static Date parseDate(Object d) { if (d == null) return new Date(); if (d instanceof Date) return (Date) d; if (d instanceof Long) return new Date(((Long) d).longValue()); if (d instanceof String) return ISODateTimeFormat.dateOptionalTimeParser().parseDateTime((String) d).toDate(); assert false; return new Date(); }
private static long toUnixTimeMicros(Object obj, Type type, String name) { if (Number.class.isAssignableFrom(obj.getClass())) { return ((Number) obj).longValue(); } else if (obj instanceof String) { String s = (String) obj; s = s.trim().replace(' ', 'T'); long millis = ISODateTimeFormat.dateOptionalTimeParser().withZone(DateTimeZone.UTC).parseMillis(s); return millis * 1000; } else { handleInvalidValue(name, type, obj); return 0; } }
/** * Constructs a YearMonthDay from an Object that represents a time, using the * specified chronology. * <p> * The recognised object types are defined in * {@link org.joda.time.convert.ConverterManager ConverterManager} and * include ReadableInstant, String, Calendar and Date. * The String formats are described by {@link ISODateTimeFormat#dateOptionalTimeParser()}. * <p> * The constructor uses the time zone of the chronology specified. * Once the constructor is complete, all further calculations are performed * without reference to a timezone (by switching to UTC). * The specified chronology overrides that of the object. * <p> * NOTE: Prior to v1.3 the string format was described by * {@link ISODateTimeFormat#dateTimeParser()}. Time only strings are now rejected. * * @param instant the datetime object, null means now * @param chronology the chronology, null means ISO default * @throws IllegalArgumentException if the instant is invalid */ public YearMonthDay(Object instant, Chronology chronology) { super(instant, DateTimeUtils.getChronology(chronology), ISODateTimeFormat.dateOptionalTimeParser()); }
/** * Constructs a YearMonthDay from an Object that represents a time, using the * specified chronology. * <p> * The recognised object types are defined in * {@link org.joda.time.convert.ConverterManager ConverterManager} and * include ReadableInstant, String, Calendar and Date. * The String formats are described by {@link ISODateTimeFormat#dateOptionalTimeParser()}. * <p> * The constructor uses the time zone of the chronology specified. * Once the constructor is complete, all further calculations are performed * without reference to a timezone (by switching to UTC). * The specified chronology overrides that of the object. * <p> * NOTE: Prior to v1.3 the string format was described by * {@link ISODateTimeFormat#dateTimeParser()}. Time only strings are now rejected. * * @param instant the datetime object, null means now * @param chronology the chronology, null means ISO default * @throws IllegalArgumentException if the instant is invalid */ public YearMonthDay(Object instant, Chronology chronology) { super(instant, DateTimeUtils.getChronology(chronology), ISODateTimeFormat.dateOptionalTimeParser()); }
private static long deserializeToMillis(Object value) { long numberOfMillis; if (value instanceof Number) { numberOfMillis = ((Number) value).longValue(); } else { // it is an extraction fn need to be parsed try { numberOfMillis = dateOptionalTimeParser().parseDateTime((String) value).getMillis(); } catch (IllegalArgumentException e) { // we may not be able to parse the date if it already comes in Hive format, // we retry and otherwise fail numberOfMillis = Timestamp.valueOf((String) value).toEpochMilli(); } } return numberOfMillis; }
/** * Constructs a YearMonthDay from an Object that represents a time. * <p> * The recognised object types are defined in * {@link org.joda.time.convert.ConverterManager ConverterManager} and * include ReadableInstant, String, Calendar and Date. * The String formats are described by {@link ISODateTimeFormat#dateOptionalTimeParser()}. * <p> * The chronology used will be derived from the object, defaulting to ISO. * <p> * NOTE: Prior to v1.3 the string format was described by * {@link ISODateTimeFormat#dateTimeParser()}. Time ony strings are now rejected. * * @param instant the datetime object, null means now * @throws IllegalArgumentException if the instant is invalid */ public YearMonthDay(Object instant) { super(instant, null, ISODateTimeFormat.dateOptionalTimeParser()); }
/** * Constructs a YearMonthDay from an Object that represents a time, using the * specified chronology. * <p> * The recognised object types are defined in * {@link org.joda.time.convert.ConverterManager ConverterManager} and * include ReadableInstant, String, Calendar and Date. * The String formats are described by {@link ISODateTimeFormat#dateOptionalTimeParser()}. * <p> * The constructor uses the time zone of the chronology specified. * Once the constructor is complete, all further calculations are performed * without reference to a timezone (by switching to UTC). * The specified chronology overrides that of the object. * <p> * NOTE: Prior to v1.3 the string format was described by * {@link ISODateTimeFormat#dateTimeParser()}. Time only strings are now rejected. * * @param instant the datetime object, null means now * @param chronology the chronology, null means ISO default * @throws IllegalArgumentException if the instant is invalid */ public YearMonthDay(Object instant, Chronology chronology) { super(instant, DateTimeUtils.getChronology(chronology), ISODateTimeFormat.dateOptionalTimeParser()); }
ISODateTimeFormat.dateOptionalTimeParser().withLocale(Locale.ROOT).withZone(DateTimeZone.UTC), ISODateTimeFormat.dateTime().withLocale(Locale.ROOT).withZone(DateTimeZone.UTC)); } else if ("dateTime".equals(input) || "date_time".equals(input)) {
public static DateTime decodeDateTime(String string) { if (Strings.isNullOrEmpty(string)) { return null; } if (string.contains("+") || Pattern.matches("-\\d", string) || string.contains(Z) || string.contains("z")) { return ISODateTimeFormat.dateOptionalTimeParser().withOffsetParsed().parseDateTime(string); } else { return ISODateTimeFormat.dateOptionalTimeParser().withZone(DateTimeZone.UTC).parseDateTime(string); } }
.toParser(); dtp = new DateTimeFormatterBuilder() .append(null, new DateTimeParser[] {time, dateOptionalTimeParser().getParser()}) .toFormatter();
/** * Create a new instance that performs date comparisons against the given attribute * using ISO date/time format parser by default. * * @param attribute Attribute name that provides candidate date values to test. */ public DateAttributePredicate(@Nonnull @NotEmpty @ParameterName(name="attribute") final String attribute) { this(attribute, ISODateTimeFormat.dateOptionalTimeParser()); }
public DateTimeTypeAdapter() { this(new DateTimeFormatterBuilder() .append(ISODateTimeFormat.dateTime().getPrinter(), ISODateTimeFormat.dateOptionalTimeParser().getParser()) .toFormatter()); }
public DateTimeTypeAdapter() { this(new DateTimeFormatterBuilder() .append(ISODateTimeFormat.dateTime().getPrinter(), ISODateTimeFormat.dateOptionalTimeParser().getParser()) .toFormatter()); }
public DateTimeTypeAdapter() { this(new DateTimeFormatterBuilder() .append(ISODateTimeFormat.dateTime().getPrinter(), ISODateTimeFormat.dateOptionalTimeParser().getParser()) .toFormatter()); }
public DateTimeTypeAdapter() { this(new DateTimeFormatterBuilder().append(ISODateTimeFormat.dateTime().getPrinter(), ISODateTimeFormat.dateOptionalTimeParser().getParser()).toFormatter()); }
public DateTimeTypeAdapter() { this(new DateTimeFormatterBuilder() .append(ISODateTimeFormat.dateTime().getPrinter(), ISODateTimeFormat.dateOptionalTimeParser().getParser()) .toFormatter()); }