public static String getISO8601String(DateTime time) { return ISODateTimeFormat.dateTime().print(time); }
@Override public String getConnectTime() { return ISODateTimeFormat.dateTime().print(stTime); }
@CheckForNull public static String formatDateTime(@Nullable Date date) { if (date != null) { return ISODateTimeFormat.dateTime().print(date.getTime()); } return null; }
@CheckForNull public static Date parseDateTime(@Nullable String s) { if (s == null) { return null; } return ISODateTimeFormat.dateTime().parseDateTime(s).toDate(); }
/** * Output the date time in ISO8601 format (yyyy-MM-ddTHH:mm:ss.SSS). * * @return ISO8601 time formatted string. */ @ToString public String toString() { return ISODateTimeFormat.dateTime().print(this); }
/** * Output the date time in ISO8601 format (yyyy-MM-ddTHH:mm:ss.SSSZZ). * * @return ISO8601 time formatted string, not null */ @ToString public String toString() { return ISODateTimeFormat.dateTime().print(this); }
/** * Output the date time in ISO8601 format (yyyy-MM-ddTHH:mm:ss.SSS). * * @return ISO8601 time formatted string. */ @ToString public String toString() { return ISODateTimeFormat.dateTime().print(this); }
/** * Output the date time in ISO8601 format (yyyy-MM-ddTHH:mm:ss.SSSZZ). * * @return ISO8601 time formatted string, not null */ @ToString public String toString() { return ISODateTimeFormat.dateTime().print(this); }
public TimeFormatExtractionFn( @JsonProperty("format") String format, @JsonProperty("timeZone") DateTimeZone tz, @JsonProperty("locale") String localeString, @JsonProperty("granularity") Granularity granularity, @JsonProperty("asMillis") boolean asMillis ) { this.format = format; this.tz = tz; this.locale = localeString == null ? null : Locale.forLanguageTag(localeString); this.granularity = granularity == null ? Granularities.NONE : granularity; if (asMillis && format == null) { Preconditions.checkArgument(tz == null, "timeZone requires a format"); Preconditions.checkArgument(localeString == null, "locale requires a format"); this.formatter = null; } else { this.formatter = (format == null ? ISODateTimeFormat.dateTime() : DateTimeFormat.forPattern(format)) .withZone(tz == null ? DateTimeZone.UTC : tz) .withLocale(locale); } this.asMillis = asMillis; }
private DateTime parseDateTime(String s) { if (Strings.isNullOrEmpty(s)) { throw new IllegalArgumentException("Null or empty string"); } final DateTimeFormatter formatter; if (s.contains("T")) { formatter = ISODateTimeFormat.dateTime(); } else { formatter = Tools.timeFormatterWithOptionalMilliseconds(); } // Use withOffsetParsed() to keep the timezone! return formatter.withOffsetParsed().parseDateTime(s); } }
break; case DATE_TIME: dateTimeFormatter = ISODateTimeFormat.dateTime(); break; default:
public String getMessage() { StringBuffer buf = new StringBuffer(85); buf.append("The"); String desc = super.getMessage(); if (desc != null) { buf.append(' '); buf.append(desc); } buf.append(" instant is "); DateTimeFormatter p = ISODateTimeFormat.dateTime(); p = p.withChronology(getBase()); if (iIsLow) { buf.append("below the supported minimum of "); p.printTo(buf, getLowerLimit().getMillis()); } else { buf.append("above the supported maximum of "); p.printTo(buf, getUpperLimit().getMillis()); } buf.append(" ("); buf.append(getBase()); buf.append(')'); return buf.toString(); }
public String getMessage() { StringBuffer buf = new StringBuffer(85); buf.append("The"); String desc = super.getMessage(); if (desc != null) { buf.append(' '); buf.append(desc); } buf.append(" instant is "); DateTimeFormatter p = ISODateTimeFormat.dateTime(); p = p.withChronology(getBase()); if (iIsLow) { buf.append("below the supported minimum of "); p.printTo(buf, getLowerLimit().getMillis()); } else { buf.append("above the supported maximum of "); p.printTo(buf, getUpperLimit().getMillis()); } buf.append(" ("); buf.append(getBase()); buf.append(')'); return buf.toString(); }
public static AbsoluteRangeEntity of(AbsoluteRange absoluteRange) { final String from = absoluteRange.from().toString(ISODateTimeFormat.dateTime()); final String to = absoluteRange.to().toString(ISODateTimeFormat.dateTime()); return builder() .from(ValueReference.of(from)) .to(ValueReference.of(to)) .build(); }
/** * Output a string in ISO8601 interval format. * <p> * From version 2.1, the string includes the time zone offset. * * @return re-parsable string (in the default zone) */ public String toString() { DateTimeFormatter printer = ISODateTimeFormat.dateTime(); printer = printer.withChronology(getChronology()); StringBuffer buf = new StringBuffer(48); printer.printTo(buf, getStartMillis()); buf.append('/'); printer.printTo(buf, getEndMillis()); return buf.toString(); }
/** * Output a string in ISO8601 interval format. * <p> * From version 2.1, the string includes the time zone offset. * * @return re-parsable string (in the default zone) */ public String toString() { DateTimeFormatter printer = ISODateTimeFormat.dateTime(); printer = printer.withChronology(getChronology()); StringBuffer buf = new StringBuffer(48); printer.printTo(buf, getStartMillis()); buf.append('/'); printer.printTo(buf, getEndMillis()); return buf.toString(); }
/** * Gets a debugging toString. * * @return a debugging string */ public String toString() { StringBuffer sb = new StringBuffer(60); sb.append("GJChronology"); sb.append('['); sb.append(getZone().getID()); if (iCutoverMillis != DEFAULT_CUTOVER.getMillis()) { sb.append(",cutover="); DateTimeFormatter printer; if (withUTC().dayOfYear().remainder(iCutoverMillis) == 0) { printer = ISODateTimeFormat.date(); } else { printer = ISODateTimeFormat.dateTime(); } printer.withChronology(withUTC()).printTo(sb, iCutoverMillis); } if (getMinimumDaysInFirstWeek() != 4) { sb.append(",mdfw="); sb.append(getMinimumDaysInFirstWeek()); } sb.append(']'); return sb.toString(); }
@ScalarFunction("to_iso8601") @SqlType("varchar(35)") // YYYY-MM-DDTHH:MM:SS.mmm+HH:MM is a standard notation, and it requires 29 characters. // However extended notation with format ±(Y)+-MM-DDTHH:MM:SS.mmm+HH:MM is also acceptable and as // the maximum year represented by 64bits timestamp is ~584944387 it may require up to 35 characters. public static Slice toISO8601FromTimestampWithTimeZone(@SqlType(StandardTypes.TIMESTAMP_WITH_TIME_ZONE) long timestampWithTimeZone) { long millisUtc = unpackMillisUtc(timestampWithTimeZone); DateTimeFormatter formatter = ISODateTimeFormat.dateTime() .withChronology(getChronology(unpackZoneKey(timestampWithTimeZone))); return utf8Slice(formatter.print(millisUtc)); }
private static Object toValue(Schema schema, PartialRow bound, Integer idx) { Type type = schema.getColumnByIndex(idx).getType(); switch (type) { case UNIXTIME_MICROS: long millis = bound.getLong(idx) / 1000; return ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC).print(millis); case STRING: return bound.getString(idx); case INT64: return bound.getLong(idx); case INT32: return bound.getInt(idx); case INT16: return bound.getShort(idx); case INT8: return (short) bound.getByte(idx); case BOOL: return bound.getBoolean(idx); case BINARY: return bound.getBinaryCopy(idx); default: throw new IllegalStateException("Unhandled type " + type + " for range partition"); } }
@ScalarFunction("to_iso8601") @SqlType("varchar(35)") // YYYY-MM-DDTHH:MM:SS.mmm+HH:MM is a standard notation, and it requires 29 characters. // However extended notation with format ±(Y)+-MM-DDTHH:MM:SS.mmm+HH:MM is also acceptable and as // the maximum year represented by 64bits timestamp is ~584944387 it may require up to 35 characters. public static Slice toISO8601FromTimestamp(ConnectorSession session, @SqlType(StandardTypes.TIMESTAMP) long timestamp) { if (session.isLegacyTimestamp()) { DateTimeFormatter formatter = ISODateTimeFormat.dateTime() .withChronology(getChronology(session.getTimeZoneKey())); return utf8Slice(formatter.print(timestamp)); } else { DateTimeFormatter formatter = ISODateTimeFormat.dateHourMinuteSecondMillis() .withChronology(UTC_CHRONOLOGY); return utf8Slice(formatter.print(timestamp)); } }