Struts 2
  1. Struts 2
  2. WW-3841

Struts 2 losing timestamp in java.util.Date when validation failed

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.3.3
    • Fix Version/s: 2.3.12
    • Component/s: Core Interceptors
    • Labels:
      None
    • Environment:

      jdk 1.6, windows

      Description

      A full example based on struts2 blank archetype attached.
      Run with maven2: mvn jetty:run
      Url: http://localhost:8080/struts-test/example/Login

      Enter as year of birth a bad integer: 1980aaa
      You'll see the timestamp still there, BUT the milliseconds are set to zero.

        Issue Links

          Activity

          Lukasz Lenart made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Lukasz Lenart made changes -
          Fix Version/s 2.3.12 [ 12324067 ]
          Fix Version/s 2.3.11 [ 12323903 ]
          Lukasz Lenart made changes -
          Fix Version/s 2.3.11 [ 12323903 ]
          Fix Version/s 2.3.10 [ 12323841 ]
          Lukasz Lenart made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Assignee Lukasz Lenart [ lukaszlenart ]
          Resolution Won't Fix [ 2 ]
          Hide
          Lukasz Lenart added a comment -

          Please re-open if you disagree

          Show
          Lukasz Lenart added a comment - Please re-open if you disagree
          Hide
          Lukasz Lenart added a comment -

          I think the problem is related how the date is displayed and why it's converted back to value without milliseconds.

          The problem is in Login.jsp which defines how to display the value:

          <s:textfield key="user.date" value='%{getText("{0,date,dd/MM/yyyy HH:mm:ss.SSS}",{user.date})}'/>
          

          but as I said before, DateConverter trims .SSS part and that's why milliseconds are dropped or rather reset to .000

          Show
          Lukasz Lenart added a comment - I think the problem is related how the date is displayed and why it's converted back to value without milliseconds. The problem is in Login.jsp which defines how to display the value: <s:textfield key= "user.date" value='%{getText( "{0,date,dd/MM/yyyy HH:mm:ss.SSS}" ,{user.date})}'/> but as I said before, DateConverter trims .SSS part and that's why milliseconds are dropped or rather reset to .000
          Hide
          Lukasz Lenart added a comment -

          That how the DateConverter was designed. You can either use Timestamp and then milliseconds are supported or to write your own converter and register it [1]

          I am not sure if changing current implementation of DateConverter is a good idea as thus can break backward compatibility.

          [1] http://struts.apache.org/2.x/docs/type-conversion.html#TypeConversion-CreatingaTypeConverter

          Show
          Lukasz Lenart added a comment - That how the DateConverter was designed. You can either use Timestamp and then milliseconds are supported or to write your own converter and register it [1] I am not sure if changing current implementation of DateConverter is a good idea as thus can break backward compatibility. [1] http://struts.apache.org/2.x/docs/type-conversion.html#TypeConversion-CreatingaTypeConverter
          Lukasz Lenart made changes -
          Fix Version/s 2.3.9 [ 12323841 ]
          Fix Version/s 2.3.8 [ 12323480 ]
          Lukasz Lenart made changes -
          Fix Version/s 2.3.8 [ 12323480 ]
          Fix Version/s 2.3.7 [ 12323448 ]
          Lukasz Lenart made changes -
          Fix Version/s 2.3.7 [ 12323448 ]
          Fix Version/s 2.3.6 [ 12323249 ]
          Lukasz Lenart made changes -
          Fix Version/s 2.3.6 [ 12323249 ]
          Fix Version/s 2.3.5 [ 12321274 ]
          J. Garcia made changes -
          Comment [ The field to consider in the example is user.date, which is of Date type. ]
          J. Garcia made changes -
          Attachment struts-test_6.zip [ 12545560 ]
          Hide
          J. Garcia added a comment -

          Previous source was incomplete. Sorry!

          Show
          J. Garcia added a comment - Previous source was incomplete. Sorry!
          J. Garcia made changes -
          Attachment struts-test_5.zip [ 12531648 ]
          Hide
          Lukasz Lenart added a comment -

          The example is invalid, user.born is an Integer not a Date

          Show
          Lukasz Lenart added a comment - The example is invalid, user.born is an Integer not a Date
          Lukasz Lenart made changes -
          Link This issue is duplicated by WW-3836 [ WW-3836 ]
          J. Garcia made changes -
          Field Original Value New Value
          Attachment struts-test_5.zip [ 12531648 ]
          J. Garcia created issue -

            People

            • Assignee:
              Lukasz Lenart
              Reporter:
              J. Garcia
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development