From commits-return-58413-apmail-harmony-commits-archive=harmony.apache.org@harmony.apache.org Thu May 07 15:49:54 2009 Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 3153 invoked from network); 7 May 2009 15:49:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 May 2009 15:49:54 -0000 Received: (qmail 90871 invoked by uid 500); 7 May 2009 15:49:53 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 90727 invoked by uid 500); 7 May 2009 15:49:52 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 90717 invoked by uid 99); 7 May 2009 15:49:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 May 2009 15:49:52 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 May 2009 15:49:50 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 93119234C041 for ; Thu, 7 May 2009 08:49:30 -0700 (PDT) Message-ID: <1803314468.1241711370601.JavaMail.jira@brutus> Date: Thu, 7 May 2009 08:49:30 -0700 (PDT) From: "Jim Yu (JIRA)" To: commits@harmony.apache.org Subject: [jira] Commented: (HARMONY-6198) [java6][classlib][sql] Timestamp.compareTo returns incorrect result In-Reply-To: <2033718301.1241678190417.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ 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.