Skip to content

Commit

Permalink
cosmetic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sonots committed Aug 26, 2017
1 parent c228074 commit 6876113
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
Expand Up @@ -139,7 +139,7 @@ else if (conditionConfig.getArgument().get() instanceof String) {
String format = (String) conditionConfig.getFormat().get();
DateTimeZone timezone = DateTimeZone.forID((String) conditionConfig.getTimezone().get());

TimestampParser parser = getTimestampParser(format, timezone);
TimestampParser parser = createTimestampParser(format, timezone);
try {
Timestamp timestamp = parser.parse(argument);
return new TimestampCondition(operator, timestamp, not);
Expand Down Expand Up @@ -220,12 +220,17 @@ public Optional<String> getDate()
}
}

private TimestampParser getTimestampParser(String format, DateTimeZone timezone)
// ToDo: Replace with `new TimestampParser(format, timezone)`
// after deciding to drop supporting embulk < 0.8.29.
private TimestampParser createTimestampParser(String format, DateTimeZone timezone)
{
return createTimestampParser(format, timezone, "1970-01-01");
}

// ToDo: Replace with `new TimestampParser(format, timezone, date)`
// after deciding to drop supporting embulk < 0.8.29.
private TimestampParser createTimestampParser(String format, DateTimeZone timezone, String date)
{
// ToDo: Use following codes after deciding to drop supporting embulk < 0.8.29.
//
// return new TimestampParser(format, timezone);
String date = "1970-01-01";
TimestampParserTaskImpl task = new TimestampParserTaskImpl(timezone, format, date);
TimestampParserColumnOptionImpl columnOption = new TimestampParserColumnOptionImpl(
Optional.of(timezone), Optional.of(format), Optional.of(date));
Expand Down
18 changes: 11 additions & 7 deletions src/main/java/org/embulk/filter/row/where/ParserLiteral.java
Expand Up @@ -180,7 +180,7 @@ void initTimestampLiteral(StringLiteral literal)
TimestampParseException ex = null;
for (String format : formats) {
try {
TimestampParser timestampParser = getTimestampParser(format, defaultTimeZone);
TimestampParser timestampParser = createTimestampParser(format, defaultTimeZone);
this.val = timestampParser.parse(literal.val);
break;
}
Expand Down Expand Up @@ -285,18 +285,22 @@ public Optional<String> getDate()
}
}

private TimestampParser getTimestampParser(String format, DateTimeZone timezone)
// ToDo: Replace with `new TimestampParser(format, timezone)`
// after deciding to drop supporting embulk < 0.8.29.
private TimestampParser createTimestampParser(String format, DateTimeZone timezone)
{
return createTimestampParser(format, timezone, "1970-01-01");
}

// ToDo: Replace with `new TimestampParser(format, timezone, date)`
// after deciding to drop supporting embulk < 0.8.29.
private TimestampParser createTimestampParser(String format, DateTimeZone timezone, String date)
{
// ToDo: Use following codes after deciding to drop supporting embulk < 0.8.29.
//
// return new TimestampParser(format, timezone);
String date = "1970-01-01";
TimestampParserTaskImpl task = new TimestampParserTaskImpl(timezone, format, date);
TimestampParserColumnOptionImpl columnOption = new TimestampParserColumnOptionImpl(
Optional.of(timezone), Optional.of(format), Optional.of(date));
return new TimestampParser(task, columnOption);
}

}

class IdentifierLiteral extends ParserLiteral
Expand Down

0 comments on commit 6876113

Please sign in to comment.