Results 1 to 3 of 3
  1. #1
    nn12 is offline Member
    Join Date
    Sep 2008
    Posts
    85
    Rep Power
    0

    Default java.sql.Date incompatible with java.sql.Timestamp

    Java Code:
      java.sql.Date leaveEffectiveDate = null;
    	  //java.sql.Timestamp leaveEffDate = null;
    	  if (rowColl != null) {
    		 Vector leaveVector = rowColl.getCollection();
    		 if (null != leaveVector && 0 != leaveVector.size()) {
    			resultRow = (Row) leaveVector.elementAt(0);
    			if(resultRow.getValue("EFF_DATE") != null){
    				leaveEffectiveDate = new java.sql.Date(((java.sql.Timestamp)resultRow.getValue("EFF_DATE")).getTime());
    				log.debug("EFFECTIVE DATE 1 >>"+leaveEffectiveDate.toString());
    			}
    	  	 }
    	  }
    	 return leaveEffectiveDate;
      }
    Any idea why I am getting this casting error?

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    10

    Default

    Because both sql.Date and TimeStamp extend util.Date, but do not extend and are not castable to each other, and the column "EFF_DATE" is, seemingly, being returned as an sql.Date object by "getValue" and you're casting it to a TimeStamp.

  3. #3
    nn12 is offline Member
    Join Date
    Sep 2008
    Posts
    85
    Rep Power
    0

Similar Threads

  1. java.util.Date vs java.sql.Date
    By Jack in forum New To Java
    Replies: 5
    Last Post: 10-28-2010, 02:59 PM
  2. Date convertion in java
    By Preethi in forum New To Java
    Replies: 25
    Last Post: 05-16-2008, 05:11 PM
  3. Using java.sql.Date
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-10-2008, 12:32 PM
  4. Java Date
    By levent in forum Java Tutorial
    Replies: 0
    Last Post: 08-05-2007, 01:57 AM
  5. Date as String to TimeStamp
    By ironballs in forum Advanced Java
    Replies: 1
    Last Post: 08-01-2007, 01:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •