Beim Lesen der Datei hat das Feld das Format org.apache.avro.generic.GenericData$Fixed.
Ich kann es nicht konvertieren LocalDateTime, da das korrekte Datum 2023-08-21 00:00:00 ist und in den Wert 8705-09-28T00:00 konvertiert wird.
Folgender Codeauszug:
InputFile file = HadoopInputFile.fromPath(this.retornaPath(fileName), hadoopConfiguration);
ParquetReader reader = AvroParquetReader.builder(file).build();
GenericRecord record;
while ((record = reader.read()) != null) {
if (fieldValue Instanz von GenericData.Fixed) {
GenericData.Fixed Fixed = (GenericData.Fixed) fieldValue;
byte[] bytes = Fixed.bytes();
LocalDate date = convertInt96ToLocalDate(bytes);
}
public static LocalDate ConvertInt96ToLocalDate(byte[] int96Bytes) {
ByteBuffer buffer = ByteBuffer.wrap(int96Bytes) .order(ByteOrder.LITTLE_ENDIAN);
Code: Select all
buffer.getLong(); // Avança 8 bytes no buffer
int daysSinceEpoch = buffer.getInt();
return LocalDate.ofEpochDay(daysSinceEpoch);
}