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

Allowing to override custom Gson Date pattern #998

Merged
merged 5 commits into from
Aug 12, 2015

Conversation

philippeehlert
Copy link
Contributor

Closes #931

@Turini Turini added this to the 4.2.0.Final milestone Aug 5, 2015
@Turini Turini changed the title Allowing to implement custom Date pattern Allowing to override custom Gson Date pattern Aug 5, 2015
@@ -41,6 +41,16 @@

If you are using JDK 8, you can use the new `java.time` API available using [vraptor-java8](/en/docs/plugins#vraptor-java-8) plugin.

You can also customize the Date pattern by implementing your own CustomDateGsonConverter and overriding the method `getPattern()`:
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about moving this doc to the end of this page, using the follow title?

#Overriding custom JSON and XML converters

It sounds better to me, because only in that point we tell how to override VRaptor beans.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds great! Just moved it to the end of the file

@Turini
Copy link
Member

Turini commented Aug 5, 2015

@Philippe2201 That sounds great! I left a simple suggestion, what do you think?
When it's done we can merge. Thank you and congrats for your first PR here ;)

@garcia-jj
Copy link
Member

garcia-jj commented Aug 5, 2015 via email

@@ -44,7 +44,7 @@
private final SimpleDateFormat iso8601Format;

public DateGsonConverter() {
this.iso8601Format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
this.iso8601Format = new SimpleDateFormat(getPattern());
Copy link
Member

Choose a reason for hiding this comment

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

Since getPattern defines the new format, this variable should renamed. My suggestion is format.

@philippeehlert
Copy link
Contributor Author

All suggestions done, but what did you suggest about Calendar?

@@ -41,25 +41,29 @@
@Dependent
public class DateGsonConverter implements JsonDeserializer<Date>, JsonSerializer<Date>{

private final SimpleDateFormat iso8601Format;
private final SimpleDateFormat format;
Copy link
Member

Choose a reason for hiding this comment

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

Drop this instance variable and [...]

@garcia-jj
Copy link
Member

@Philippe2201 Calendar and Date are very similar, except that Calendar have timezone information. So since you are changing the GsonDateConverter, the change change can be applied to GsonCalendarConverter, if you want. So my suggestion is apply the same change to GsonCalendarConverter, keeping both converters with same behavior.

@garcia-jj
Copy link
Member

This pull request will be very useful. Thank you @Philippe2201.

@philippeehlert
Copy link
Contributor Author

Great! Just pushed the last modifications

@Turini
Copy link
Member

Turini commented Aug 12, 2015

@Philippe2201 could you update your docs, changing the return to DateFormat?

@garcia-jj
Copy link
Member

🚀

@philippeehlert
Copy link
Contributor Author

@Turini yes! just did it

@Turini
Copy link
Member

Turini commented Aug 12, 2015

thank you so much, merging here

Turini added a commit that referenced this pull request Aug 12, 2015
Allowing to override custom Gson Date pattern
@Turini Turini merged commit fa3adfd into caelum:master Aug 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants