protected void write( Date value, Writer writer ) throws IOException { String isoDate = Bson.getDateFormatter().format(value); write(new BasicDocument(DATE, isoDate), writer); }
protected void write( Date value, Writer writer ) throws IOException { String isoDate = Bson.getDateFormatter().format(value); write(new BasicDocument(DATE, isoDate), writer); }
@Test public void shouldCorrectlyWriteDate() { Date now = new Date(); String dateStr = Bson.getDateFormatter().format(now); String expected = "{ \"$date\" : \"" + dateStr + "\" }"; String actual = writer.write(now); assertSame(expected, actual); }
@Test public void shouldParseIsoDateWithZuluTimeZone() throws Exception { Date date = now(); value = JsonReader.DATE_VALUE_MATCHER.parseValue(Bson.getDateFormatter().format(date)); assertTrue(value instanceof Date); }