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

          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
          Hide
          J. Garcia added a comment -

          Previous source was incomplete. Sorry!

          Show
          J. Garcia added a comment - Previous source was incomplete. Sorry!
          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
          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 -

          Please re-open if you disagree

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

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Development