getHours
public int getHours()Deprecated.   This method is deprecated and should not be used because SQL Date values do not have a time component. 據説是因爲SQL的日期不含有time部分

解决方案 »

  1.   

    GregorianCalendar calendar = new GregorianCalendar();
    calendar.setTime(date);
    int hour = calendar.get(Calendar.HOUR_OF_DAY);HOUR_OF_DAY是Calendar类的静态域,类似还可以取得其他好多的值
      

  2.   

    String theDate="2005-01-25";    
    java.text.SimpleDateFormat sdf=new java.text.SimpleDateFormat("yyyy-MM-dd");
    Calendar cla=Calendar.getInstance();
    cla.setTime(sdf.parse(theDate));
    cla.get(Calendar.DAY_OF_WEEK)-1)--------星期
    cla.get(Calendar.HOUR_OF_DAY)--------小时
      

  3.   

    简单点,转换成String,然后截取