public static Date stringToDate(String str) { DateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Date date = null; try { // Fri Feb 24 00:00:00 CST 2012 date = format.parse(str); } catch (ParseException e) { e.printStackTrace(); } // 2012-02-24 date = java.sql.Date.valueOf(str); return date; }
Date startDate=stringToDate(startTime);
Java:String转换为date类型
时间: 2024-11-03 22:16:34