Github user barrotsteindev commented on a diff in the pull request: https://github.com/apache/lucene-solr/pull/428#discussion_r207742308 --- Diff: solr/core/src/java/org/apache/solr/update/processor/ParseDateFieldUpdateProcessorFactory.java --- @@ -172,4 +181,34 @@ public void init(NamedList args) { return (null == type) || type instanceof DateValueFieldType; }; } + + public static void validateFormatter(DateTimeFormatter formatter) { + // check it's valid via round-trip + try { + parseInstant(formatter, formatter.format(Instant.now())); + } catch (Exception e) { + throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, + "Bad or unsupported pattern: " + formatter.toFormat().toString(), e); + } + } + + private static Instant parseInstant(DateTimeFormatter formatter, String dateStr) { + final TemporalAccessor temporalAccessor = formatter.parse(dateStr); + // parsed successfully. But is it a full instant or just to the day? + if (temporalAccessor.isSupported(ChronoField.INSTANT_SECONDS)) { // has time + // has offset time + if(temporalAccessor.isSupported(ChronoField.OFFSET_SECONDS)) { --- End diff -- Oh wow can't believe I missed that. This seems so much more robust then the previous version.
--- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org