@Test
public void getDateAsIso8601String() {

    // Note: The before field is -360000000L, the after is +360000000L vs ET
    final Date date_2016_12_22_at_midnight = new Date(1482022800000L);
    final Date date_2016_12_23_at_midnight = new Date(1482829200000L);
    final String iso8601Date = "2016-12-22T12:00:00.000Z";
    Date ocrDate = null;
    assertNull(new OcrResponseParser(null).getDate());
    assertNull(new OcrResponseParser(new OcrResponse(null, null, null, null, null, null, null, null)).getDate());
    assertNull(new OcrResponseParser(new OcrResponse(null, null, null, new OcrResponseField<>(null, 1.0), null, null, null, null)).getDate());
    // Change timezone and test
    TestTimezoneToggler.setDefaultTimeZone(TimeZone.getTimeZone("America/New_York"));
    ocrDate = new OcrResponseParser(new OcrResponse(null, null, null, new OcrResponseField<>(iso8601Date, 1.0), null, null, null, null)).getDate();
    assertNotNull(ocrDate);
    assertTrue(ocrDate.after(date_2016_12_22_at_midnight));
    assertTrue(ocrDate.before(date_2016_12_23_at_midnight));
    assertTrue(getDateAsIso8601String(ocrDate).startsWith("2016-12-22"));
    // Change timezone and test
    TestTimezoneToggler.setDefaultTimeZone(TimeZone.getTimeZone("Europe/London"));
    ocrDate = new OcrResponseParser(new OcrResponse(null, null, null, new OcrResponseField<>(iso8601Date, 1.0), null, null, null, null)).getDate();
    assertNotNull(ocrDate);
    assertTrue(ocrDate.after(date_2016_12_22_at_midnight));
    assertTrue(ocrDate.before(date_2016_12_23_at_midnight));
    assertTrue(getDateAsIso8601String(ocrDate).startsWith("2016-12-22"));
    // Change timezone and test
    TestTimezoneToggler.setDefaultTimeZone(TimeZone.getTimeZone("Australia/Sydney"));
    ocrDate = new OcrResponseParser(new OcrResponse(null, null, null, new OcrResponseField<>(iso8601Date, 1.0), null, null, null, null)).getDate();
    assertNotNull(ocrDate);
    assertTrue(ocrDate.after(date_2016_12_22_at_midnight));
    assertTrue(ocrDate.before(date_2016_12_23_at_midnight));
    assertTrue(getDateAsIso8601String(ocrDate).startsWith("2016-12-22"));
    // Change timezone and test
    TestTimezoneToggler.setDefaultTimeZone(TimeZone.getTimeZone("Asia/Istanbul"));
    ocrDate = new OcrResponseParser(new OcrResponse(null, null, null, new OcrResponseField<>(iso8601Date, 1.0), null, null, null, null)).getDate();
    assertNotNull(ocrDate);
    assertTrue(ocrDate.after(date_2016_12_22_at_midnight));
    assertTrue(ocrDate.before(date_2016_12_23_at_midnight));
    assertTrue(getDateAsIso8601String(ocrDate).startsWith("2016-12-22"));
}