discomarathon / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

Ability to configure date pattern #307

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
It would be nice to configure a date pattern for an attribute, in the 
annotation, like :

@DatePattern("yyyy-mm-dd")
private Date day;

The configuration in GsonBuilder is useful to change date pattern each time, 
but it can be useful to change configuration for only one attribute.

Original issue reported on code.google.com by mick8...@gmail.com on 6 Apr 2011 at 1:08

GoogleCodeExporter commented 9 years ago
This is a valid feature request and I will look into supporting something like 
this in the next Gson release.

I see this feature functioning such that you define your own annotations (like 
above) and provide your own type adapter; however, the JsonSerializer or 
JsonDeserializer will have enough context to pull off the field and class 
annotations.

Original comment by joel.leitch@gmail.com on 13 Apr 2011 at 7:30

GoogleCodeExporter commented 9 years ago

Original comment by joel.leitch@gmail.com on 13 Apr 2011 at 7:30

GoogleCodeExporter commented 9 years ago
I came across feature request while trying to do this exact thing with the GSON 
lib earier today.
I had a go at modding the GSON code to support this, its a little rough but it 
may help someone out if they need to do this in the future, maybe even provide 
a starting point to something like this being implemented in future releases. 

See attached SVN patch file

Original comment by donalfen...@gmail.com on 9 Feb 2014 at 11:09

Attachments: