/** * Parses a {@code LocalTime} from the specified string. * <p> * This uses {@link ISODateTimeFormat#localTimeParser()}. * * @param str the string to parse, not null * @since 2.0 */ @FromString public static LocalTime parse(String str) { return parse(str, ISODateTimeFormat.localTimeParser()); }
/** * Parses a {@code LocalTime} from the specified string. * <p> * This uses {@link ISODateTimeFormat#localTimeParser()}. * * @param str the string to parse, not null * @since 2.0 */ @FromString public static LocalTime parse(String str) { return parse(str, ISODateTimeFormat.localTimeParser()); }
@Override public long getLong(int field) { checkState(row != null, "No current row"); Column column = columns.get(field); if (column.getType().getBase() == ColumnType.Base.DATE) { return Days.daysBetween(new LocalDate(0), LocalDate.parse(row.get(column.getPosition()))).getDays(); } if (column.getType().getBase() == ColumnType.Base.TIME) { return LocalTime.parse(row.get(column.getPosition())).getMillisOfDay(); } if (column.getType().getBase() == ColumnType.Base.INTEGER) { return parseInt(row.get(column.getPosition())); } if (column.getType().getBase() == ColumnType.Base.DECIMAL) { DecimalParseResult decimalParseResult = Decimals.parse(row.get(column.getPosition())); return rescale((Long) decimalParseResult.getObject(), decimalParseResult.getType().getScale(), ((DecimalType) columnTypes.get(field)).getScale()); } return parseLong(row.get(column.getPosition())); }
ByteBuffer.wrap(b), LocalDate.parse("2014-03-01"), LocalTime.parse("12:12:12"), 123456, DateTime.parse("2014-03-01T12:12:12.321Z"),
localDate = localDateTime.toLocalTime(); } else { localDate = LocalTime.parse(text);
public static User generateRandomUser(Random rnd) { return new User( generateRandomString(rnd, 50), rnd.nextBoolean() ? null : rnd.nextInt(), rnd.nextBoolean() ? null : generateRandomString(rnd, 6), rnd.nextBoolean() ? null : rnd.nextLong(), rnd.nextDouble(), null, rnd.nextBoolean(), generateRandomStringList(rnd, 20, 30), generateRandomBooleanList(rnd, 20), rnd.nextBoolean() ? null : generateRandomStringList(rnd, 20, 20), generateRandomColor(rnd), new HashMap<>(), generateRandomFixed16(rnd), generateRandomUnion(rnd), generateRandomAddress(rnd), generateRandomBytes(rnd), LocalDate.parse("2014-03-01"), LocalTime.parse("12:12:12"), 123456, DateTime.parse("2014-03-01T12:12:12.321Z"), 123456L, ByteBuffer.wrap(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray()), new Fixed2(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray())); }
@Override public User map(Tuple3<String, Integer, String> value) { User user = new User(); user.setName(value.f0); user.setFavoriteNumber(value.f1); user.setFavoriteColor(value.f2); user.setTypeBoolTest(true); user.setTypeArrayString(Collections.emptyList()); user.setTypeArrayBoolean(Collections.emptyList()); user.setTypeEnum(Colors.BLUE); user.setTypeMap(Collections.emptyMap()); user.setTypeBytes(ByteBuffer.allocate(10)); user.setTypeDate(LocalDate.parse("2014-03-01")); user.setTypeTimeMillis(LocalTime.parse("12:12:12")); user.setTypeTimeMicros(123456); user.setTypeTimestampMillis(DateTime.parse("2014-03-01T12:12:12.321Z")); user.setTypeTimestampMicros(123456L); // 20.00 user.setTypeDecimalBytes(ByteBuffer.wrap(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray())); // 20.00 user.setTypeDecimalFixed(new Fixed2(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray())); return user; } }
localDate = localDateTime.toLocalTime(); } else { localDate = LocalTime.parse(text);
private void output(final AvroOutputFormat<User> outputFormat) throws IOException { outputFormat.configure(new Configuration()); outputFormat.open(1, 1); for (int i = 0; i < 100; i++) { User user = new User(); user.setName("testUser"); user.setFavoriteNumber(1); user.setFavoriteColor("blue"); user.setTypeBoolTest(true); user.setTypeArrayString(Collections.emptyList()); user.setTypeArrayBoolean(Collections.emptyList()); user.setTypeEnum(Colors.BLUE); user.setTypeMap(Collections.emptyMap()); user.setTypeBytes(ByteBuffer.allocate(10)); user.setTypeDate(LocalDate.parse("2014-03-01")); user.setTypeTimeMillis(LocalTime.parse("12:12:12")); user.setTypeTimeMicros(123456); user.setTypeTimestampMillis(DateTime.parse("2014-03-01T12:12:12.321Z")); user.setTypeTimestampMicros(123456L); // 20.00 user.setTypeDecimalBytes(ByteBuffer.wrap(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray())); // 20.00 user.setTypeDecimalFixed(new Fixed2(BigDecimal.valueOf(2000, 2).unscaledValue().toByteArray())); outputFormat.writeRecord(user); } outputFormat.close(); }
user1.setTypeBytes(ByteBuffer.allocate(10)); user1.setTypeDate(LocalDate.parse("2014-03-01")); user1.setTypeTimeMillis(LocalTime.parse("12:12:12")); user1.setTypeTimeMicros(123456); user1.setTypeTimestampMillis(DateTime.parse("2014-03-01T12:12:12.321Z")); .setTypeBytes(ByteBuffer.allocate(10)) .setTypeDate(LocalDate.parse("2014-03-01")) .setTypeTimeMillis(LocalTime.parse("12:12:12")) .setTypeTimeMicros(123456) .setTypeTimestampMillis(DateTime.parse("2014-03-01T12:12:12.321Z"))
user1.setTypeBytes(ByteBuffer.allocate(10)); user1.setTypeDate(LocalDate.parse("2014-03-01")); user1.setTypeTimeMillis(LocalTime.parse("12:12:12")); user1.setTypeTimeMicros(123456); user1.setTypeTimestampMillis(DateTime.parse("2014-03-01T12:12:12.321Z")); .setTypeBytes(ByteBuffer.allocate(10)) .setTypeDate(LocalDate.parse("2014-03-01")) .setTypeTimeMillis(LocalTime.parse("12:12:12")) .setTypeTimeMicros(123456) .setTypeTimestampMillis(DateTime.parse("2014-03-01T12:12:12.321Z")) user.setTypeBytes(ByteBuffer.allocate(10)); user.setTypeDate(LocalDate.parse("2014-03-01")); user.setTypeTimeMillis(LocalTime.parse("12:12:12")); user.setTypeTimeMicros(123456); user.setTypeTimestampMillis(DateTime.parse("2014-03-01T12:12:12.321Z"));
user.put("type_bytes", ByteBuffer.allocate(10)); user.put("type_date", LocalDate.parse("2014-03-01")); user.put("type_time_millis", LocalTime.parse("12:12:12")); user.put("type_time_micros", 123456); user.put("type_timestamp_millis", DateTime.parse("2014-03-01T12:12:12.321Z"));
.setTypeBytes(ByteBuffer.allocate(10)) .setTypeDate(LocalDate.parse("2014-03-01")) .setTypeTimeMillis(LocalTime.parse("12:12:12")) .setTypeTimeMicros(123456) .setTypeTimestampMillis(DateTime.parse("2014-03-01T12:12:12.321Z"))
/** * Parses a {@code LocalTime} from the specified string. * <p> * This uses {@link ISODateTimeFormat#localTimeParser()}. * * @param str the string to parse, not null * @since 2.0 */ @FromString public static LocalTime parse(String str) { return parse(str, ISODateTimeFormat.localTimeParser()); }
@Override public LocalTime convertValue(String value, Type type) { return LocalTime.parse(value); } }
/** * Parses a {@code LocalTime} from the specified string. * <p> * This uses {@link ISODateTimeFormat#localTimeParser()}. * * @param str the string to parse, not null * @since 2.0 */ @FromString public static LocalTime parse(String str) { return parse(str, ISODateTimeFormat.localTimeParser()); }
/** * Parses a {@code LocalTime} from the specified string. * <p> * This uses {@link ISODateTimeFormat#localTimeParser()}. * * @param str the string to parse, not null * @since 2.0 */ @FromString public static LocalTime parse(String str) { return parse(str, ISODateTimeFormat.localTimeParser()); }
/** * Parses a {@code LocalTime} from the specified string. * <p> * This uses {@link ISODateTimeFormat#localTimeParser()}. * * @param str the string to parse, not null * @since 2.0 */ @FromString public static LocalTime parse(String str) { return parse(str, ISODateTimeFormat.localTimeParser()); }
/** * Parses a {@code LocalTime} from the specified string. * <p> * This uses {@link ISODateTimeFormat#localTimeParser()}. * * @param str the string to parse, not null * @since 2.0 */ @FromString public static LocalTime parse(String str) { return parse(str, ISODateTimeFormat.localTimeParser()); }
public static Duration parseDurationFromTime(String time) { if (StringUtils.isEmpty(time)) { return null; } return Duration.millis(LocalTime.parse(time, new DateTimeFormatterBuilder().appendPattern(TimePattern).toFormatter()).getMillisOfDay()); }