src/main/java/org/embulk/parser/avro/getter/FloatColumnGetter.java in embulk-parser-avro-0.2.0 vs src/main/java/org/embulk/parser/avro/getter/FloatColumnGetter.java in embulk-parser-avro-0.3.0
- old
+ new
@@ -1,17 +1,20 @@
package org.embulk.parser.avro.getter;
+import org.embulk.parser.avro.TimestampUnit;
import org.embulk.spi.Column;
import org.embulk.spi.PageBuilder;
-import org.embulk.spi.time.Timestamp;
import org.embulk.spi.time.TimestampParser;
public class FloatColumnGetter extends BaseColumnGetter {
protected Float value;
- public FloatColumnGetter(PageBuilder pageBuilder, TimestampParser[] timestampParsers) {
+ private final TimestampUnit[] timestampUnits;
+
+ public FloatColumnGetter(PageBuilder pageBuilder, TimestampParser[] timestampParsers, TimestampUnit[] timestampUnits) {
super(pageBuilder, timestampParsers);
+ this.timestampUnits = timestampUnits;
}
@Override
public void setValue(Object value)
{
@@ -49,10 +52,10 @@
public void timestampColumn(Column column) {
if (this.value == null) {
pageBuilder.setNull(column);
}
else {
- long milliSec = (long) (value * 1000);
- pageBuilder.setTimestamp(column, Timestamp.ofEpochMilli(milliSec));
+ TimestampUnit unit = timestampUnits[column.getIndex()];
+ pageBuilder.setTimestamp(column, unit.toTimestamp(value.doubleValue()));
}
}
}