http://expert.csdn.net/Expert/topic/1669/1669661.xml?temp=.3121454

解决方案 »

  1.   

    public static java.sql.Date getSqlDate(String year, String month, String date) {
        int y = 100;
        int m = 2;
        int d = 1;
        if (year != null) {
          y = Integer.parseInt(year) - 1900;
        }
        if (month != null) {
          m = Integer.parseInt(month) - 1;
        }
        if (date != null) {
          d = Integer.parseInt(date);
        }
        java.sql.Date SqlDate = new java.sql.Date(y, m, d);
        return SqlDate;
      }
      

  2.   

    import java.text.SimpleDateFormat;
    用simpledateformat格式化String.
      

  3.   

    DateFormat df =new SimpleDateFormat("yyyy 年 MM 月 dd 日 HH:mm:ss");// yyyy年,MM月,dd日 hh(HH 24小时):mm:ss
        //  你的字符串要有哪些字符串就行.
        //  比如你new一个()  (大小写m是月和分钟,不过到底哪个大写小写我忘了 :)
         // 然后你的字符串 2002年3月4日 12:22:22
          java.util.Date date = df.parse("2002 年 03 月 04 日 12:22:22");
    System.out.println(date) ;
      

  4.   

    java.text.DateFormat formatter = new java.text.SimpleDateFormat("yyyy-MM-dd");//"yyyy-MM-dd"日期格式
    Date theDate=formatter.parse(searchdate);//searchdate为string类型的日期