struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lukasz Lenart <>
Subject Re: Set timezone in jsonwriter for date conversion
Date Thu, 05 Nov 2015 14:53:23 GMT
Yeah, right now it's hard. I think the best option is to write your
own JSON result with all the custom stuff you need - JSONWriter &
JSONUtil. I'm going to refactor JSON plugin to be more extensible but
it won't happen till Struts 2.5.

+ 48 606 323 122

2015-11-05 1:05 GMT+01:00 JOSE L MARTINEZ-AVIAL <>:
> Hello,
>    Let me clarify the issue I have. I would like to be able to customize
> the way the JSON plugin formats the date when converting an objecto to
> json. Specifically, when I'm returning a JSONResult to a client. In order
> to do that I need to modify the DateFormatter used by JSONWriter so I can
> change its timezone. I took a look at the code, and it seems that make that
> modification is going to be hard. It would be something like this:
>   Extend JSONWriter to be able to use timezone with a Date(Maybe receiving
> the timezone as a parameter, or using annotation at the field level)
>   Extend JSONUtil to call my custom JSONWriter.
>   Extend JSONResult to call my customer JSONUtil, by overriding the method
> createJSONString. This would pretty much imply copy the whole code, as the
> method has a bunch of dependences from private variables when calling
> JSONUtil.
> Can anyone suggest a better approach?
> JL
> 2015-11-03 14:13 GMT-05:00 JOSE L MARTINEZ-AVIAL <>:
>> Hello,
>>    I'm using Struts I use the json plugin to return information
>> to the client (browser and ios App). The problem I have is that the
>> dates/times are local to my server, and since I have the option to know the
>> client's timezone, I would like to return the date to the client converted
>> to his local time. In order to do that I need to set the timezone of the
>> DateFormatter used by the json plugin. I don't see any issue way to do
>> that, apart from extending JSONWriter. Is that something possible? how I
>> would indicate the plugin to use my own version of JSONWriter?
>> Thanks
>> JL

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message