Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XContentBuilder doesn't handle Java Calendar #2911

Closed
lucaslward opened this issue Apr 17, 2013 · 0 comments
Closed

XContentBuilder doesn't handle Java Calendar #2911

lucaslward opened this issue Apr 17, 2013 · 0 comments

Comments

@lucaslward
Copy link

Calendar calendar = new GregorianCalendar();
String expectedCalendar = XContentBuilder.defaultDatePrinter.print(calendar.getTimeInMillis());
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
builder.startObject().field("calendar", calendar).endObject();
assertThat(builder.string(), equalTo("{\"calendar\":\"" + expectedCalendar + "\"}"));

The above will fail because the builder would have just called toString() on Calendar, even though it's trivial to say calendar.getTime() (which returns a normal Date)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant