harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jim Yu (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-6198) [java6][classlib][sql] Timestamp.compareTo returns incorrect result
Date Thu, 07 May 2009 15:49:30 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-6198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12706946#action_12706946
] 

Jim Yu commented on HARMONY-6198:
---------------------------------

Hi Regis,

I also noticed the issue you mentioned. But in Java 5 spec., it explicitly mentions
 "Throws:  ClassCastException - if the argument is not a Timestamp object" while
in Java 6 spec not. And for RI's behavior, it throws ClassCastException in JDK 
1.5.0_06 but in 1.5.0_07 it does not.

> [java6][classlib][sql] Timestamp.compareTo returns incorrect result
> -------------------------------------------------------------------
>
>                 Key: HARMONY-6198
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6198
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M9
>            Reporter: Jim Yu
>         Attachments: HARMONY-6198.diff
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> I found Timestamp.compareTo(Date) would return 1 even when both the timestamp and date
object are constructed with the same millisecond values. There is testcase below. I've made
a fix to solve the problem.
> import java.sql.Timestamp;
> import java.util.Date;
> public class TimeStampComp {
>     /**
>      * @param args
>      */
>     public static void main(String[] args) {
>         long time = System.currentTimeMillis();
>         Date date = new Date(time);
>         Timestamp timestamp = new Timestamp(date.getTime());
>         System.out.println("compareTo returns " + timestamp.compareTo(date));
>     }
> }
> Result of RI:
> compareTo returns 0
> Result of Harmony:
> compareTo returns 1

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


Mime
View raw message