Derby
  1. Derby
  2. DERBY-4621

Invalid conversion from Timestamp to String when calling setTimestamp() with Calendar

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 10.5.3.0
    • Fix Version/s: 10.5.3.1, 10.6.1.0
    • Component/s: SQL
    • Labels:
      None
    • Issue & fix info:
      Repro attached
    • Bug behavior facts:
      Wrong query result

      Description

      If you set a VARCHAR parameter with setTimestamp(), the string will be formatted differently depending on whether a Calendar is specified or not, even if the default calendar is used.

      Take for example this statement:

      VALUES CAST(? AS VARCHAR(30))

      I executed this statement twice with the same Timestamp instance. First like this:

      ps.setTimestamp(1, ts);

      and then like this

      ps.setTimestamp(1, ts, Calendar.getInstance());

      In this example, both of the methods should use the default Calendar to convert the timestamp to a string. However, I see that they generate different strings:

      2010-04-20 15:17:36.0 vs 2010-04-20 03:17:36

      Note there are two differences:

      1) The method that takes a Calendar object does not show the fraction part (.0)

      2) The method that takes a Calendar object is 12 hours off (03 instead of 15)

      1. TimestampToVarchar.java
        0.8 kB
        Knut Anders Hatlen
      2. derby-4621.diff
        4 kB
        Knut Anders Hatlen

        Issue Links

          Activity

          Knut Anders Hatlen created issue -
          Knut Anders Hatlen made changes -
          Field Original Value New Value
          Attachment TimestampToVarchar.java [ 12442291 ]
          Knut Anders Hatlen made changes -
          Assignee Knut Anders Hatlen [ knutanders ]
          Issue & fix info [Repro attached]
          Knut Anders Hatlen made changes -
          Link This issue blocks DERBY-4582 [ DERBY-4582 ]
          Knut Anders Hatlen made changes -
          Component/s SQL [ 11408 ]
          Component/s JDBC [ 11407 ]
          Knut Anders Hatlen made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          Knut Anders Hatlen made changes -
          Attachment derby-4621.diff [ 12442304 ]
          Knut Anders Hatlen made changes -
          Status In Progress [ 3 ] Resolved [ 5 ]
          Fix Version/s 10.6.0.0 [ 12313727 ]
          Resolution Fixed [ 1 ]
          Knut Anders Hatlen made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Kathey Marsden made changes -
          Link This issue is required by DERBY-4728 [ DERBY-4728 ]
          Kathey Marsden made changes -
          Resolution Fixed [ 1 ]
          Status Closed [ 6 ] Reopened [ 4 ]
          Mamta A. Satoor made changes -
          Assignee Knut Anders Hatlen [ knutanders ] Mamta A. Satoor [ mamtas ]
          Mamta A. Satoor made changes -
          Assignee Mamta A. Satoor [ mamtas ] Knut Anders Hatlen [ knutanders ]
          Fix Version/s 10.5.3.1 [ 12314182 ]
          Mamta A. Satoor made changes -
          Status Reopened [ 4 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Knut Anders Hatlen made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Gavin made changes -
          Workflow jira [ 12508875 ] Default workflow, editable Closed status [ 12800466 ]

            People

            • Assignee:
              Knut Anders Hatlen
              Reporter:
              Knut Anders Hatlen
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development