de.bytefish.pgbulkinsert.pgsql.handlers.LocalDateValueHandler 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.LocalDateConverter;
import java.io.DataOutputStream;
import java.time.LocalDate;
public class LocalDateValueHandler extends BaseValueHandler {
private IValueConverter dateConverter;
public LocalDateValueHandler() {
this(new LocalDateConverter());
}
public LocalDateValueHandler(IValueConverter dateTimeConverter) {
this.dateConverter = dateTimeConverter;
}
@Override
protected void internalHandle(DataOutputStream buffer, final LocalDate value) throws Exception {
buffer.writeInt(4);
buffer.writeInt(dateConverter.convert(value));
}
@Override
public int getLength(LocalDate value) {
return 4;
}
}