Github user dsmiley commented on a diff in the pull request:
https://github.com/apache/lucene-solr/pull/428#discussion_r207641129
--- Diff:
solr/core/src/test/org/apache/solr/update/processor/ParsingFieldUpdateProcessorsTest.java
---
@@ -50,10 +55,9 @@ public void testParseDateRoundTrip() throws Exception {
String dateString = "2010-11-12T13:14:15.168Z";
SolrInputDocument d = processAdd("parse-date", doc(f("id", "9"),
f("date_dt", dateString)));
assertNotNull(d);
- DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.dateTime();
- DateTime dateTime = dateTimeFormatter.parseDateTime(dateString);
+ ZonedDateTime localDateTime = ZonedDateTime.parse(dateString,
DateTimeFormatter.ISO_DATE_TIME);
assertTrue(d.getFieldValue("date_dt") instanceof Date);
- assertEquals(dateTime.getMillis(), ((Date)
d.getFieldValue("date_dt")).getTime());
+
assertEquals(localDateTime.withZoneSameInstant(ZoneOffset.UTC).toInstant().toEpochMilli(),
((Date) d.getFieldValue("date_dt")).getTime());
--- End diff --
Simply change the left arg to `Instant.parse(dateString)` (and call
toInstant() on the right arg instead of getTime()), and remove the couple lines
above that are no longer needed :-)
Part of the work involved, I think, isn't always doing a direct Joda ->
java.time API translation, but it's also recognizing when the code in question
is needlessly verbose and making it better. I try to take that philosophy with
any code maintenance. There's a lot of cases in this test suite where you can
apply the above technique to remove needless time API machinery that is
needless.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]