java.sql.Date如何转换为java.util.Date?

解决方案 »

  1.   

    java.util.Date d = new java.util.Date(sqlDate.getTime());
      

  2.   

    java.sql.Date是java.util.Date的子类,为何要转化
      

  3.   


    java.sql.Date sqldate = null;
    java.util.Date utildate = sqldate;
    1楼那样做也行 没实验过 通常取出来的时候to_char过的 要么就是orm工具直接给映射成了util的Date了
      

  4.   


    /*
     * @(#)Date.java 1.33 04/05/18
     *
     * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
     * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
     */package java.sql;/**
     * <P>A thin wrapper around a millisecond value that allows
     * JDBC to identify this as an SQL <code>DATE</code> value.  A 
     * milliseconds value represents the number of milliseconds that 
     * have passed since January 1, 1970 00:00:00.000 GMT.
     * <p>
     * To conform with the definition of SQL <code>DATE</code>, the 
     * millisecond values wrapped by a <code>java.sql.Date</code> instance 
     * must be 'normalized' by setting the 
     * hours, minutes, seconds, and milliseconds to zero in the particular
     * time zone with which the instance is associated.
     */
    public class Date extends java.util.Date {
        ...
        ...
    }顶LS的
      

  5.   

    估计是楼主想将util date转化为sql date吧