Skip to content

Commit b46a4f3

Browse files
committed
Merge these two sets of methods together
1 parent 17b3ee3 commit b46a4f3

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/DateProcessor.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,6 @@ public final class DateProcessor extends AbstractProcessor {
9494
formatter = DateFormatter.forPattern(this.outputFormat);
9595
}
9696

97-
private static ZoneId newDateTimeZone(String timezone) {
98-
return timezone == null ? ZoneOffset.UTC : ZoneId.of(timezone);
99-
}
100-
101-
private static Locale newLocale(String locale) {
102-
return locale == null ? Locale.ENGLISH : LocaleUtils.parse(locale);
103-
}
104-
10597
@Override
10698
public IngestDocument execute(IngestDocument document) {
10799
Object obj = document.getFieldValue(field, Object.class);
@@ -149,12 +141,22 @@ public String getType() {
149141

150142
// visible for testing
151143
ZoneId getTimezone(IngestDocument document) {
152-
return newDateTimeZone(timezone == null ? null : document.renderTemplate(timezone));
144+
String value = timezone == null ? null : document.renderTemplate(timezone);
145+
if (value == null) {
146+
return ZoneOffset.UTC;
147+
} else {
148+
return ZoneId.of(value);
149+
}
153150
}
154151

155152
// visible for testing
156153
Locale getLocale(IngestDocument document) {
157-
return newLocale(locale == null ? null : document.renderTemplate(locale));
154+
String value = locale == null ? null : document.renderTemplate(locale);
155+
if (value == null) {
156+
return Locale.ENGLISH;
157+
} else {
158+
return LocaleUtils.parse(value);
159+
}
158160
}
159161

160162
String getField() {

0 commit comments

Comments
 (0)