protected String transformMillisToSDF(long millisSinceEpoch) { // convert to date time (with timezone), then truncate/bucket to the desired output granularity return _dateTimeTruncate.truncate(new DateTime(millisSinceEpoch, _outputDateTimeFormatter.getZone())); }
/** * Extracts the values of the partial from an object of this converter's type. * This method checks if the parser has a zone, and uses it if present. * This is most useful for parsing local times with UTC. * * @param fieldSource a partial that provides access to the fields. * This partial may be incomplete and only getFieldType(int) should be used * @param object the object to convert * @param chrono the chronology to use, which is the non-null result of getChronology() * @param parser the parser to use, may be null * @return the array of field values that match the fieldSource, must be non-null valid * @throws ClassCastException if the object is invalid * @throws IllegalArgumentException if the value if invalid * @since 1.3 */ public int[] getPartialValues(ReadablePartial fieldSource, Object object, Chronology chrono, DateTimeFormatter parser) { if (parser.getZone() != null) { chrono = chrono.withZone(parser.getZone()); } long millis = parser.withChronology(chrono).parseMillis((String) object); return chrono.get(fieldSource, millis); }
/** * Extracts the values of the partial from an object of this converter's type. * This method checks if the parser has a zone, and uses it if present. * This is most useful for parsing local times with UTC. * * @param fieldSource a partial that provides access to the fields. * This partial may be incomplete and only getFieldType(int) should be used * @param object the object to convert * @param chrono the chronology to use, which is the non-null result of getChronology() * @param parser the parser to use, may be null * @return the array of field values that match the fieldSource, must be non-null valid * @throws ClassCastException if the object is invalid * @throws IllegalArgumentException if the value if invalid * @since 1.3 */ public int[] getPartialValues(ReadablePartial fieldSource, Object object, Chronology chrono, DateTimeFormatter parser) { if (parser.getZone() != null) { chrono = chrono.withZone(parser.getZone()); } long millis = parser.withChronology(chrono).parseMillis((String) object); return chrono.get(fieldSource, millis); }
@Override public ZoneId zone() { return DateUtils.dateTimeZoneToZoneId(printer.getZone()); }
public JacksonJodaDateFormat(DateTimeFormatter defaultFormatter) { super(); _formatter = defaultFormatter; DateTimeZone tz = defaultFormatter.getZone(); _jdkTimezone = (tz == null) ? null : tz.toTimeZone(); _explicitTimezone = false; _adjustToContextTZOverride = null; _writeZoneId = null; }
@Override public TimeZone getTimeZone() { return formatter.getZone().toTimeZone(); } }
/** * Extracts the values of the partial from an object of this converter's type. * This method checks if the parser has a zone, and uses it if present. * This is most useful for parsing local times with UTC. * * @param fieldSource a partial that provides access to the fields. * This partial may be incomplete and only getFieldType(int) should be used * @param object the object to convert * @param chrono the chronology to use, which is the non-null result of getChronology() * @param parser the parser to use, may be null * @return the array of field values that match the fieldSource, must be non-null valid * @throws ClassCastException if the object is invalid * @throws IllegalArgumentException if the value if invalid * @since 1.3 */ public int[] getPartialValues(ReadablePartial fieldSource, Object object, Chronology chrono, DateTimeFormatter parser) { if (parser.getZone() != null) { chrono = chrono.withZone(parser.getZone()); } long millis = parser.withChronology(chrono).parseMillis((String) object); return chrono.get(fieldSource, millis); }
@Override public TimeZone getTimeZone() { return formatter.getZone().toTimeZone(); } }
private static DateTimeFormatter withZone(DateTimeFormatter dateTimeFormatter, DateTimeZone zoneId) { if (zoneId != null) { return dateTimeFormatter.withZone(zoneId); } else if (dateTimeFormatter.getZone() == null) { return dateTimeFormatter.withZone(DateTimeZone.getDefault()); } return dateTimeFormatter; }
@Override public TimeZone getTimeZone() { return formatter.getZone().toTimeZone(); } }
@Override public String encodePartition(SinkRecord sinkRecord) { long timestamp = System.currentTimeMillis(); DateTime bucket = new DateTime(getPartition(partitionDurationMs, timestamp, formatter.getZone())); return bucket.toString(formatter); }
@Override public String encodePartition(JobContext context, IEtlKey key) { return Long.toString(DateUtils.getPartition(outfilePartitionMillis, key.getTime(), outputDirFormatter.getZone())); }
@Override public String encodePartition(JobContext context, IEtlKey key) { return Long.toString(DateUtils.getPartition(outfilePartitionMillis, key.getTime(), outputDirFormatter.getZone())); }
/** * Extracts the values of the partial from an object of this converter's type. * This method checks if the parser has a zone, and uses it if present. * This is most useful for parsing local times with UTC. * * @param fieldSource a partial that provides access to the fields. * This partial may be incomplete and only getFieldType(int) should be used * @param object the object to convert * @param chrono the chronology to use, which is the non-null result of getChronology() * @param parser the parser to use, may be null * @return the array of field values that match the fieldSource, must be non-null valid * @throws ClassCastException if the object is invalid * @throws IllegalArgumentException if the value if invalid * @since 1.3 */ public int[] getPartialValues(ReadablePartial fieldSource, Object object, Chronology chrono, DateTimeFormatter parser) { if (parser.getZone() != null) { chrono = chrono.withZone(parser.getZone()); } long millis = parser.withChronology(chrono).parseMillis((String) object); return chrono.get(fieldSource, millis); }
/** * Extracts the values of the partial from an object of this converter's type. * This method checks if the parser has a zone, and uses it if present. * This is most useful for parsing local times with UTC. * * @param fieldSource a partial that provides access to the fields. * This partial may be incomplete and only getFieldType(int) should be used * @param object the object to convert * @param chrono the chronology to use, which is the non-null result of getChronology() * @param parser the parser to use, may be null * @return the array of field values that match the fieldSource, must be non-null valid * @throws ClassCastException if the object is invalid * @throws IllegalArgumentException if the value if invalid * @since 1.3 */ public int[] getPartialValues(ReadablePartial fieldSource, Object object, Chronology chrono, DateTimeFormatter parser) { if (parser.getZone() != null) { chrono = chrono.withZone(parser.getZone()); } long millis = parser.withChronology(chrono).parseMillis((String) object); return chrono.get(fieldSource, millis); }
/** * Extracts the values of the partial from an object of this converter's type. * This method checks if the parser has a zone, and uses it if present. * This is most useful for parsing local times with UTC. * * @param fieldSource a partial that provides access to the fields. * This partial may be incomplete and only getFieldType(int) should be used * @param object the object to convert * @param chrono the chronology to use, which is the non-null result of getChronology() * @param parser the parser to use, may be null * @return the array of field values that match the fieldSource, must be non-null valid * @throws ClassCastException if the object is invalid * @throws IllegalArgumentException if the value if invalid * @since 1.3 */ public int[] getPartialValues(ReadablePartial fieldSource, Object object, Chronology chrono, DateTimeFormatter parser) { if (parser.getZone() != null) { chrono = chrono.withZone(parser.getZone()); } long millis = parser.withChronology(chrono).parseMillis((String) object); return chrono.get(fieldSource, millis); }
/** * Extracts the values of the partial from an object of this converter's type. * This method checks if the parser has a zone, and uses it if present. * This is most useful for parsing local times with UTC. * * @param fieldSource a partial that provides access to the fields. * This partial may be incomplete and only getFieldType(int) should be used * @param object the object to convert * @param chrono the chronology to use, which is the non-null result of getChronology() * @param parser the parser to use, may be null * @return the array of field values that match the fieldSource, must be non-null valid * @throws ClassCastException if the object is invalid * @throws IllegalArgumentException if the value if invalid * @since 1.3 */ public int[] getPartialValues(ReadablePartial fieldSource, Object object, Chronology chrono, DateTimeFormatter parser) { if (parser.getZone() != null) { chrono = chrono.withZone(parser.getZone()); } long millis = parser.withChronology(chrono).parseMillis((String) object); return chrono.get(fieldSource, millis); }
@Override public String encodePartition(JobContext context, IEtlKey key) { long outfilePartitionMs = EtlMultiOutputFormat.getEtlOutputFileTimePartitionMins(context) * 60000L; return "" + DateUtils.getPartition(outfilePartitionMs, key.getTime(), outputDateFormatter.getZone()); }
@Override public String encodePartition(JobContext context, IEtlKey key) { long outfilePartitionMs = EtlMultiOutputFormat.getEtlOutputFileTimePartitionMins(context) * 60000L; return "" + DateUtils.getPartition(outfilePartitionMs, key.getTime(), outputDateFormatter.getZone()); }
@SuppressWarnings("unchecked") @Override public ContextualConverter<? super I, ? extends O> newConverter(ConvertingTypes targetedTypes, ContextFactoryBuilder contextFactoryBuilder, Object... params) { DateTimeFormatter[] dateTimeFormatters = JodaTimeHelper.getDateTimeFormatters(params); DateTimeZone zoneId = JodaTimeHelper.getDateTimeZoneOrDefault(params); ContextualConverter<I, O>[] converters = new ContextualConverter[dateTimeFormatters.length]; for(int i = 0; i < dateTimeFormatters.length; i++) { DateTimeFormatter dateTimeFormatter = dateTimeFormatters[i]; if (dateTimeFormatter.getZone() == null) { dateTimeFormatter.withZone(zoneId); } converters[i] = newConverter(dateTimeFormatter); } if (converters.length == 1) { return converters[0]; } else { return new MultiDateTimeFormatterConverter<I, O>(converters); } }