Re: The different output with Date whether the Http request have application/json
I wouldn't mix the REST plugin (which has it's own JSON handler) with the JSON plugin - use one or another. Regards -- Łukasz mobile +48 606 323 122 http://www.lenart.org.pl/ - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: The different output with Date whether the Http request have application/json
After few more hours searching I figure out that struts2-rest-plugin is using jacksion for parsing lib And the ObjectMapper will turn Date Object into millionseconds So struts2-rest-plugin will be first pick after access action when responsing (if no application/json header its will be pass not process) then struts2-json-plugin (using DefaultJsonWriter) in struts2-rest-plugin its first into DefaultContentTypeHandlerManager choosing which ContentTypeHandler to use (in this case the result is JacksonJsonHandler ) Then in JacksonJsonHandler its will use ObjectMapper transfer Date I believe which is reason why change my default date format string into millionseconds and all other ContentTypeHandlers may also cause issue due to also use jacksion lib Is this some kinds of Feature or Bug? If this is bug can someone help me report this issue? 於 2023年12月4日 週一 下午8:58寫道: > > HI Thanks for reply > Yes its does change to what i format > but not with if the request with application/json > app still return millionseconds > > and after a day for testing > I finally find out its nothing about struts2-json-plugin > > > its struts2-rest-plugin cause the issue !! > > > if i add this plugin > The Date Object will turn to millionseconds > But I didnt see any word about it at official page > https://struts.apache.org/plugins/rest/ > > here is my action code === > > import java.util.Date; > import com.opensymphony.xwork2.Action; > import com.opensymphony.xwork2.ModelDriven; > public class TmpAction implements ModelDriven { > private Date model = new Date(); > public Date getModel() { > return model; > } > public void setModel(Date model) { > this.model = model; > } > public String index() { > return Action.SUCCESS; > } > } > > === > here is my struts.xml === > > "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN" > "http://struts.apache.org/dtds/struts-2.5.dtd;> > > > > namespace="/api"> > class="TmpAction" method="index"> > > model > > > > > > > here is part of maven pom.xml the dependencies i have use === > > > org.apache.struts > struts2-core > 6.3.0 > > > org.apache.struts > struts2-json-plugin > 6.3.0 > > > org.apache.logging.log4j > log4j-core > 2.17.0 > > > org.apache.logging.log4j > log4j-api > 2.17.0 > > > org.apache.struts > struts2-rest-plugin > 6.3.0 > > > com.fasterxml.jackson.dataformat > jackson-dataformat-xml > 2.16.0 > > > === > > If still need more information > I can offer github repository to reporduce this issue > Best regards > > Yasser Zamani 於 2023年12月4日 週一 上午3:24寫道: > > > > Hi, > > > > Thanks for reaching out! > > > > Could you please try setting your desired value to Struts constant > > "struts.json.dateformat" and see if any change happens? Or try > > https://stackoverflow.com/a/59471917? > > > > Regards, > > Yasser > > > > > > > > From: > > Sent: Saturday, December 2, 2023 4:21 PM > > To: user@struts.apache.org > > Subject: The different output with Date whether the Http request have > > application/json > > > > Hi all: > > > > I am new of use struts framework , and when I have a request with no > > application/json to my app which use Struts framework having json > > plugin , The Date Object return is something like > > “2015-05-04T10:08:15+00:00” which is RFC 3339 format , Its fine . > > > > But when I have request with header have application/json , The Date > > Object return is something like 1701522508943 . I believe which > > represent the millionseconds since January 1, 1970, 00:00:00 GMT . But > > how ? I didn’t see any article mention it . And I didn’t get any tips > > from source code . The DefaultJSONWriter seems not doing this ? > > > > Can someone tell me how and which java class turn the Date Object to > > number and sent to front ? > > > > - > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > > For additional commands, e-mail: user-h...@struts.apache.org > > > > > > - > > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > > For additional commands, e-mail: user-h...@struts.apache.org > > - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: The different output with Date whether the Http request have application/json
HI Thanks for reply Yes its does change to what i format but not with if the request with application/json app still return millionseconds and after a day for testing I finally find out its nothing about struts2-json-plugin its struts2-rest-plugin cause the issue !! if i add this plugin The Date Object will turn to millionseconds But I didnt see any word about it at official page https://struts.apache.org/plugins/rest/ here is my action code === import java.util.Date; import com.opensymphony.xwork2.Action; import com.opensymphony.xwork2.ModelDriven; public class TmpAction implements ModelDriven { private Date model = new Date(); public Date getModel() { return model; } public void setModel(Date model) { this.model = model; } public String index() { return Action.SUCCESS; } } === here is my struts.xml === http://struts.apache.org/dtds/struts-2.5.dtd;> model here is part of maven pom.xml the dependencies i have use === org.apache.struts struts2-core 6.3.0 org.apache.struts struts2-json-plugin 6.3.0 org.apache.logging.log4j log4j-core 2.17.0 org.apache.logging.log4j log4j-api 2.17.0 org.apache.struts struts2-rest-plugin 6.3.0 com.fasterxml.jackson.dataformat jackson-dataformat-xml 2.16.0 === If still need more information I can offer github repository to reporduce this issue Best regards Yasser Zamani 於 2023年12月4日 週一 上午3:24寫道: > > Hi, > > Thanks for reaching out! > > Could you please try setting your desired value to Struts constant > "struts.json.dateformat" and see if any change happens? Or try > https://stackoverflow.com/a/59471917? > > Regards, > Yasser > > > > From: > Sent: Saturday, December 2, 2023 4:21 PM > To: user@struts.apache.org > Subject: The different output with Date whether the Http request have > application/json > > Hi all: > > I am new of use struts framework , and when I have a request with no > application/json to my app which use Struts framework having json > plugin , The Date Object return is something like > “2015-05-04T10:08:15+00:00” which is RFC 3339 format , Its fine . > > But when I have request with header have application/json , The Date > Object return is something like 1701522508943 . I believe which > represent the millionseconds since January 1, 1970, 00:00:00 GMT . But > how ? I didn’t see any article mention it . And I didn’t get any tips > from source code . The DefaultJSONWriter seems not doing this ? > > Can someone tell me how and which java class turn the Date Object to > number and sent to front ? > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > > - > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: The different output with Date whether the Http request have application/json
Hi, Thanks for reaching out! Could you please try setting your desired value to Struts constant "struts.json.dateformat" and see if any change happens? Or try https://stackoverflow.com/a/59471917? Regards, Yasser From: Sent: Saturday, December 2, 2023 4:21 PM To: user@struts.apache.org Subject: The different output with Date whether the Http request have application/json Hi all: I am new of use struts framework , and when I have a request with no application/json to my app which use Struts framework having json plugin , The Date Object return is something like “2015-05-04T10:08:15+00:00” which is RFC 3339 format , Its fine . But when I have request with header have application/json , The Date Object return is something like 1701522508943 . I believe which represent the millionseconds since January 1, 1970, 00:00:00 GMT . But how ? I didn’t see any article mention it . And I didn’t get any tips from source code . The DefaultJSONWriter seems not doing this ? Can someone tell me how and which java class turn the Date Object to number and sent to front ? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
The different output with Date whether the Http request have application/json
Hi all: I am new of use struts framework , and when I have a request with no application/json to my app which use Struts framework having json plugin , The Date Object return is something like “2015-05-04T10:08:15+00:00” which is RFC 3339 format , Its fine . But when I have request with header have application/json , The Date Object return is something like 1701522508943 . I believe which represent the millionseconds since January 1, 1970, 00:00:00 GMT . But how ? I didn’t see any article mention it . And I didn’t get any tips from source code . The DefaultJSONWriter seems not doing this ? Can someone tell me how and which java class turn the Date Object to number and sent to front ? - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org