Skip to content

Commit

Permalink
Merge pull request #58 from embulk/replace-joda-time-usage
Browse files Browse the repository at this point in the history
Remove joda time usage
  • Loading branch information
himadieievsv authored Jul 14, 2020
2 parents 99017e7 + 97d55b0 commit 9e705b9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: java

jdk:
- oraclejdk8
- openjdk8

services:
- docker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
import org.embulk.config.ConfigDefault;
import org.embulk.config.ConfigDiff;
import org.embulk.config.ConfigException;
import org.embulk.config.ConfigSource;
import org.embulk.config.Task;
import org.embulk.config.TaskReport;
import org.embulk.spi.Exec;
import org.embulk.spi.Schema;
import org.embulk.spi.time.TimestampFormatter;
import org.joda.time.DateTimeZone;
import org.slf4j.Logger;

import java.util.List;
Expand Down Expand Up @@ -226,22 +224,10 @@ public void validateOutputTask(PluginTask task, Schema embulkSchema, int taskCou
}
}

private static interface FormatterIntlTask extends Task, TimestampFormatter.Task {}
private static interface FormatterIntlColumnOption extends Task, TimestampFormatter.TimestampColumnOption {}

@Override // Overridden from |ServiceRequestMapperBuildable|
public JacksonServiceRequestMapper buildServiceRequestMapper(PluginTask task)
{
// TODO: Switch to a newer TimestampFormatter constructor after a reasonable interval.
// Traditional constructor is used here for compatibility.
final ConfigSource configSource = Exec.newConfigSource();
configSource.set("format", "%Y-%m-%dT%H:%M:%S.%3N%z");
configSource.set("timezone", DateTimeZone.forID(task.getTimeZone()));
TimestampFormatter formatter = TimestampFormatter.of(
Exec.newConfigSource().loadConfig(FormatterIntlTask.class),
com.google.common.base.Optional.fromNullable(configSource.loadConfig(FormatterIntlColumnOption.class))
);

TimestampFormatter formatter = TimestampFormatter.of("%Y-%m-%dT%H:%M:%S.%3N%z", task.getTimeZone());
return JacksonServiceRequestMapper.builder()
.add(new JacksonAllInObjectScope(formatter, task.getFillNullForEmptyColumn()), new JacksonTopLevelValueLocator("record"))
.build();
Expand Down

0 comments on commit 9e705b9

Please sign in to comment.