You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Knut Anders Hatlen (JIRA)" <ji...@apache.org> on 2010/04/21 13:23:50 UTC

[jira] Updated: (DERBY-4626) Timestamp truncated when converted to string with explicit calendar

     [ https://issues.apache.org/jira/browse/DERBY-4626?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Knut Anders Hatlen updated DERBY-4626:
--------------------------------------

    Attachment: TimestampToVarchar.java

The attached class, TimestampToVarchar, shows the difference between the two methods. Note these two differences:

  1) The setTimestamp() method that takes a Calendar truncates nanoseconds so that the resulting resolution is microseconds. The method that doesn't take a Calendar preserves the nanoseconds.

  2) The setTimestamp() method that takes a Calendar does not remove trailing zeros, whereas the method that doesn't take a Calendar does remove trailing zeros (except if the fraction is zero).

Here's the output of the repro on trunk:

Testing timestamp:  2010-04-20 15:17:36.123456789
- without calendar: 2010-04-20 15:17:36.123456789
- with    calendar: 2010-04-20 15:17:36.123457

Testing timestamp:  2010-04-20 15:17:36.12345678
- without calendar: 2010-04-20 15:17:36.12345678
- with    calendar: 2010-04-20 15:17:36.123457

Testing timestamp:  2010-04-20 15:17:36.1234567
- without calendar: 2010-04-20 15:17:36.1234567
- with    calendar: 2010-04-20 15:17:36.123457

Testing timestamp:  2010-04-20 15:17:36.123456
- without calendar: 2010-04-20 15:17:36.123456
- with    calendar: 2010-04-20 15:17:36.123456

Testing timestamp:  2010-04-20 15:17:36.12345
- without calendar: 2010-04-20 15:17:36.12345
- with    calendar: 2010-04-20 15:17:36.123450

Testing timestamp:  2010-04-20 15:17:36.1234
- without calendar: 2010-04-20 15:17:36.1234
- with    calendar: 2010-04-20 15:17:36.123400

Testing timestamp:  2010-04-20 15:17:36.123
- without calendar: 2010-04-20 15:17:36.123
- with    calendar: 2010-04-20 15:17:36.123000

Testing timestamp:  2010-04-20 15:17:36.12
- without calendar: 2010-04-20 15:17:36.12
- with    calendar: 2010-04-20 15:17:36.120000

Testing timestamp:  2010-04-20 15:17:36.1
- without calendar: 2010-04-20 15:17:36.1
- with    calendar: 2010-04-20 15:17:36.100000

Testing timestamp:  2010-04-20 15:17:36.0
- without calendar: 2010-04-20 15:17:36.0
- with    calendar: 2010-04-20 15:17:36.0

> Timestamp truncated when converted to string with explicit calendar
> -------------------------------------------------------------------
>
>                 Key: DERBY-4626
>                 URL: https://issues.apache.org/jira/browse/DERBY-4626
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.5.3.0
>            Reporter: Knut Anders Hatlen
>         Attachments: TimestampToVarchar.java
>
>
> When setting the value of a VARCHAR parameter with setTimestamp() the timestamp is truncated to microsecond resolution if a calendar is specified. Nanosecond resolution is preserved when a calendar is not specified. These two methods should behave the same way. Since Derby supports nanosecond resolution, the timestamps should not be truncated.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.