de.bytefish.pgbulkinsert.pgsql.handlers.LocalDateTimeValueHandler Maven / Gradle / Ivy
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
package de.bytefish.pgbulkinsert.pgsql.handlers;
import de.bytefish.pgbulkinsert.pgsql.converter.IValueConverter;
import de.bytefish.pgbulkinsert.pgsql.converter.LocalDateTimeConverter;
import java.io.DataOutputStream;
import java.time.LocalDateTime;
public class LocalDateTimeValueHandler extends BaseValueHandler {
private IValueConverter dateTimeConverter;
public LocalDateTimeValueHandler() {
this(new LocalDateTimeConverter());
}
public LocalDateTimeValueHandler(IValueConverter dateTimeConverter) {
this.dateTimeConverter = dateTimeConverter;
}
@Override
protected void internalHandle(DataOutputStream buffer, final LocalDateTime value) throws Exception {
buffer.writeInt(8);
buffer.writeLong(dateTimeConverter.convert(value));
}
@Override
public int getLength(LocalDateTime value) {
return 8;
}
}