package org.embulk.parser.apache.log;

import org.embulk.spi.PageBuilder;
import org.embulk.spi.time.Timestamp;
import org.embulk.spi.time.TimestampParser;


import static org.embulk.spi.type.Types.TIMESTAMP;


public class TimestampLogElement extends LogElement<Timestamp> {

    private final TimestampParser parser;

    public TimestampLogElement(TimestampParser.Task task, String name, String regex) {
        this(task, name, regex, "%d/%b/%Y:%T %z");
    }

    public TimestampLogElement(TimestampParser.Task task, String name, String regex, String pattern) {
        super(name, regex, TIMESTAMP);
        this.parser = new TimestampParser(task.getJRuby(), pattern, task.getDefaultTimeZone());
    }

    @Override
    public Timestamp parse(String s) {
        try{
            return parser.parse(s);
        }catch (Exception e){
            return null;
        }
    }

    @Override
    public void setToPageBuilder(PageBuilder pageBuilder, int i, String value) {
        Timestamp parse = parse(value);
        if(parse != null){
            pageBuilder.setTimestamp(i, parse);
        }else{
            pageBuilder.setNull(i);
        }
    }
}

@@ -30,24 +30,125 @@
 che.log;%0D%0A%0D%0A
+import org.embulk.config.ConfigSource;%0D%0Aimport org.embulk.config.Task;%0D%0Aimport org.embulk.spi.Exec;%0D%0A
 import org.e
@@ -573,24 +573,217 @@
 ;%0D%0A    %7D%0D%0A%0D%0A
+    private static interface ParserIntlTask extends Task, TimestampParser.Task %7B%7D%0D%0A    private static interface ParserIntlColumnOption extends Task, TimestampParser.TimestampColumnOption %7B%7D%0D%0A%0D%0A
     public T
@@ -926,25 +926,34 @@
     
-this.parser =
+// TODO: Switch to a
  new
+er
  Tim
@@ -968,59 +968,476 @@
 rser
-(task.getJRuby(), pattern, task.getDefaultTimeZone(
+ constructor after a reasonable interval.%0D%0A        // Traditional constructor is used here for compatibility.%0D%0A        final ConfigSource configSource = Exec.newConfigSource();%0D%0A        configSource.set(%22format%22, pattern);%0D%0A        configSource.set(%22timezone%22, task.getDefaultTimeZone());%0D%0A        this.parser = new TimestampParser(%0D%0A            Exec.newConfigSource().loadConfig(ParserIntlTask.class),%0D%0A            configSource.loadConfig(ParserIntlColumnOption.class
 ));%0D

Use traditional constructors of TimestampParser against Embulk core deprecation