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<Object> {
  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 ===
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
        "http://struts.apache.org/dtds/struts-2.5.dtd";>

<struts>
<constant name="struts.json.dateformat" value="dd/MM/yyyy" />
   <package name="api" extends="json-default"
        namespace="/api">
        <action name="/tmp/*"
            class="TmpAction" method="index">
            <result type="json">
                <param name="root">model</param>
            </result>
        </action>
    </package>
</struts>

====
here is part of maven pom.xml the dependencies i have use  ===
    <dependencies>
        <dependency>
            <groupId>org.apache.struts</groupId>
            <artifactId>struts2-core</artifactId>
            <version>6.3.0</version>
        </dependency>
        <dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-json-plugin</artifactId>
<version>6.3.0</version>
</dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.17.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.17.0</version>
        </dependency>
        <dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-rest-plugin</artifactId>
<version>6.3.0</version>
</dependency>
<dependency>
    <groupId>com.fasterxml.jackson.dataformat</groupId>
    <artifactId>jackson-dataformat-xml</artifactId>
    <version>2.16.0</version>
</dependency>
    </dependencies>
===

If still need more information
I can offer github repository to reporduce this issue
Best regards

Yasser Zamani <yasserzam...@apache.org> 於 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: 哈哈哈哈 <yangg9...@gmail.com>
> 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

Reply via email to