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

Knut Anders Hatlen updated DERBY-4752:
--------------------------------------

    Attachment: remove-cheap-formatter.stat
                remove-cheap-formatter.diff

Here's a patch that removes CheapDateFormatter and makes the callers
use java.util.Date instead. CheapDateFormatter used to convert the
timestamps to GMT, whereas Date.toString() will use the local time
zone. Date.toString() also formats the timestamp differently. So,
where CheapDateFormatter produces a timestamp like

  2010-08-18 11:38:59.755 GMT

we will now print something like this instead:

  Wed Aug 18 13:38:59 CEST 2010

I think either one of these two formats works just as well as the
other for logging purposes, but others may disagree.

Full list of changes made by the patch:

M       java/engine/org/apache/derby/impl/services/monitor/BaseMonitor.java

Removed unused imports, including CheapDateFormatter. No actual use of
CheapDateFormatter in this class.

M       java/engine/org/apache/derby/impl/services/locks/Timeout.java

Use Date.toString() instead of CheapDateFormatter to format the
timestamp included in timeout exceptions when
derby.locks.deadlockTrace has been set.

M       java/engine/org/apache/derby/impl/services/stream/BasicGetLogHeader.java

Use Date.toString() to produce the timestamp in the log stream header.

M       
java/engine/org/apache/derby/impl/store/raw/data/BaseDataFileFactory.java

Use Date.toString() instead of CheapDateFormatter when writing the
startup and shutdown messages to derby.log. Also removed unused
imports, including CheapDateFormatter.

M       java/drda/org/apache/derby/impl/drda/NetworkServerControlImpl.java

Use Date instead of CheapDateFormatter when server prints console
messages.

D       java/engine/org/apache/derby/iapi/util/CheapDateFormatter.java
D       
java/testing/org/apache/derbyTesting/unitTests/junit/CheapDateFormatterTest.java
M       java/testing/org/apache/derbyTesting/unitTests/junit/_Suite.java

Removed CheapDateFormatter class and its unit tests.

A       
java/testing/org/apache/derbyTesting/functionTests/tests/tools/derbyrunjartest_sed.properties
M       
java/testing/org/apache/derbyTesting/functionTests/master/derbyrunjartest.out

Filter out a line with a timestamp from derbyrunjartest since the
format of the timestamp has changed and isn't caught by the old
filters.

> CheapDateFormatter returns incorrect and invalid date strings
> -------------------------------------------------------------
>
>                 Key: DERBY-4752
>                 URL: https://issues.apache.org/jira/browse/DERBY-4752
>             Project: Derby
>          Issue Type: Bug
>          Components: Services
>    Affects Versions: 10.7.0.0
>            Reporter: Knut Anders Hatlen
>            Assignee: Knut Anders Hatlen
>            Priority: Minor
>             Fix For: 10.7.0.0
>
>         Attachments: CheapFormatterPerfTest.java, derby-4752-1a.diff, 
> derby-4752-1b.diff, derby-4752-1c.diff, remove-cheap-formatter.diff, 
> remove-cheap-formatter.stat
>
>
> CheapDateFormatter has multiple problems. These are the ones I'm aware of:
> 1) On the boundary between non-leap years and leap years it will return first 
> day of thirteenth month in previous year (for instance, 2011-13-01 instead of 
> 2012-01-01)
> 2) It treats all years divisible by four as leap years. Those divisible by 
> 100 and not by 400 are not leap years. It attempts to adjust for that (see 
> the snippet below) but it always ends up setting leapYear=true if (year%4)==0.
>               // It's a leap year if divisible by 4, unless divisible by 100,
>               // unless divisible by 400.
>               if ((year % 4L) == 0) {
>                       if ((year % 100L) == 0) {
>                               if ((year % 400L) == 0) {
>                                       leapYear = true;
>                               }
>                       }
>                       leapYear = true;
>               }
> 3) More leap year trouble. To find out which year it is, it calculates the 
> number of four year periods that have elapsed since 1970-01-01. A four year 
> period is considered 365*3+366 days. Although most four year periods are of 
> that length, some are shorter, so we'll get one day off starting from year 
> 2100, two days off from year 2200, and so on.

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

Reply via email to