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

Change Calendar Deserializer to accepts json object format #547

Merged
merged 3 commits into from
Aug 28, 2013

Conversation

dipold
Copy link
Member

@dipold dipold commented Jul 3, 2013

The Calendar Serializer produces a json like this:
{"time":1301886000000,"timezone":"America/Sao_Paulo"}

But the Calendar Deserializer ignore this format.
This Calendar Deserializer fix the problem and check if json is a primitive or object before parsing it.

{"time":1301886000000,"timezone":"America/Sao_Paulo"}

Add test to validate this format
Long time = value.get("time").getAsLong();

calendar.setTimeZone(TimeZone.getTimeZone(timezone));
calendar.setTimeInMillis(time);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird indent here

@garcia-jj
Copy link
Member

I think that we need to accept ISO8601 format as described in #544, since this ISO is a standard.

@dipold
Copy link
Member Author

dipold commented Jul 3, 2013

Humm.. I'll take a closer look at it

@dipold
Copy link
Member Author

dipold commented Jul 4, 2013

Adopt ISO8601 format will generate a compatibility break, because it's easy to adopt various formats to deserialize, but must be chosen only one format to serialize.
Should I change the current pull request and adopt the ISO8601 format to serialize and deserialize and write java.util.Date and Calendar serializer and deserializer?
What do you think?

@dipold
Copy link
Member Author

dipold commented Jul 4, 2013

More details:
The ISO8601 is fully supported only by SimpleDateFormat in a Java 7 and JodaTime.
Other way is create a utility class convertion by replacement regexp rules but, is hard to do and I don´t believe that will support 100% of ISO8601 specs.
Any suggestions?

@garcia-jj
Copy link
Member

@dipold, vraptor needs to be compliant with JDK5. Can you test if yyyy-MM-dd'T'HH:mm:ssZ pattern works to you? I don't have Java 6 (and 5) version in my machine.

I'll ask @lucascs regarding ISO8601 sooner.

Thank you.

doesn't have time and timezone properties and if these values are
invalid
@dipold
Copy link
Member Author

dipold commented Jul 4, 2013

@garcia-jj
This pattern works with some reservations:
The big problem is that 'Z' in the JDK < 7 is a RFC 822 time zone standart.

The RFC 822 standart support time zones like: "GMT", "GMT-03:00" and "-0300"
The ISO8601 standart support time zones like: "Z", "-03:00", "-0300" and "-03";

Sees the differences? The only similarity is the format "-0300".

So.. the only String date that works in the pattern yyyy-MM-dd'T'HH:mm:ssZ is: 2013-07-04T18:09:30-0300

Full support to the ISO8601 standard must support the patterns:
yyyy-MM-dd'T'HH:mm:ssZ
yyyyMMdd'T'HHmmssZ
Where 'T' and 'Z' and 'ss' and 'mm' are optional and 'Z' support time zones like: "Z", "±HH:mm", "±HHmm" and "±HH";

@garcia-jj
Copy link
Member

Understood. So I think that we can postpone this pattern to later. Thank you.

@lucascs lucascs merged commit 97d4f62 into caelum:master Aug 28, 2013
@lucascs
Copy link
Member

lucascs commented Aug 28, 2013

Thanks!

@dipold dipold deleted the fixGson branch August 28, 2013 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants