|
8 | 8 | import org.embulk.config.ConfigSource;
|
9 | 9 | import org.embulk.config.Task;
|
10 | 10 | import org.embulk.spi.Exec;
|
11 |
| -import org.embulk.spi.time.TimestampFormatter; |
12 | 11 | import org.embulk.output.jdbc.BatchInsert;
|
13 | 12 | import org.embulk.output.jdbc.JdbcColumn;
|
14 | 13 | import org.embulk.output.jdbc.JdbcColumnOption;
|
15 | 14 | import org.embulk.config.ConfigException;
|
| 15 | +import org.embulk.util.timestamp.TimestampFormatter; |
16 | 16 |
|
17 | 17 | public class ColumnSetterFactory
|
18 | 18 | {
|
@@ -77,28 +77,11 @@ public ColumnSetter newColumnSetter(JdbcColumn column, JdbcColumnOption option)
|
77 | 77 | }
|
78 | 78 | }
|
79 | 79 |
|
80 |
| - private static interface FormatterIntlTask extends Task, TimestampFormatter.Task {} |
81 |
| - private static interface FormatterIntlColumnOption extends Task, TimestampFormatter.TimestampColumnOption {} |
82 |
| - |
83 | 80 | protected TimestampFormatter newTimestampFormatter(JdbcColumnOption option)
|
84 | 81 | {
|
85 |
| - // TODO: Switch to a newer TimestampFormatter constructor after a reasonable interval. |
86 |
| - // Traditional constructor is used here for compatibility. |
87 |
| - final ConfigSource configSource = Exec.newConfigSource(); |
88 |
| - configSource.set("format", option.getTimestampFormat().getFormat()); |
89 |
| - configSource.set("timezone", getTimeZone(option)); |
90 |
| - |
91 |
| - final FormatterIntlTask task = Exec.newConfigSource().loadConfig(FormatterIntlTask.class); |
92 |
| - final Optional<? extends TimestampFormatter.TimestampColumnOption> columnOption = |
93 |
| - Optional.ofNullable(configSource.loadConfig(FormatterIntlColumnOption.class)); |
94 |
| - |
95 |
| - return TimestampFormatter.of( |
96 |
| - columnOption.isPresent() |
97 |
| - ? columnOption.get().getFormat().or(task.getDefaultTimestampFormat()) |
98 |
| - : task.getDefaultTimestampFormat(), |
99 |
| - columnOption.isPresent() |
100 |
| - ? columnOption.get().getTimeZoneId().or(task.getDefaultTimeZoneId()) |
101 |
| - : task.getDefaultTimeZoneId()); |
| 82 | + final String format = option.getTimestampFormat().getFormat(); |
| 83 | + final String timezone = option.getTimeZone().orElse(this.defaultTimeZone); |
| 84 | + return TimestampFormatter.builder(format, true).setDefaultZoneFromString(timezone).build(); |
102 | 85 | }
|
103 | 86 |
|
104 | 87 | protected Calendar newCalendar(JdbcColumnOption option)
|
|
0 commit comments