String str=new String("2003-6-17"); 
Date tt1=Date.valueOf(str);//java.sql.Date
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 
Date tt2= sdf.parse(str);//java.util.Date

解决方案 »

  1.   

    笨方法:
    int j = (new Integer(str.substring(0, 4))).intValue();
    int k = (new Integer(str.substring(5, 7))).intValue();
    int l = (new Integer(str.substring(8, 10))).intValue();
    GregorianCalendar gregoriancalendar = new GregorianCalendar(j, k, l);
      

  2.   

    String str = "2000-1-1 12:12:12"
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); 
    Date date = formatter.parse(str);