-
Notifications
You must be signed in to change notification settings - Fork 329
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
Conversation
@@ -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()`: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
@Philippe2201 That sounds great! I left a simple suggestion, what do you think? |
And about Calendar?
|
@@ -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()); |
There was a problem hiding this comment.
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
.
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; |
There was a problem hiding this comment.
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 [...]
@Philippe2201 |
This pull request will be very useful. Thank you @Philippe2201. |
Great! Just pushed the last modifications |
@Philippe2201 could you update your docs, changing the return to DateFormat? |
🚀 |
@Turini yes! just did it |
thank you so much, merging here |
Allowing to override custom Gson Date pattern
Closes #931