SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd");//設置時間格式
String data = “1999-0-9”;//創建String類型的變量
Date ts=null;//創建Date對象
try {
ts = sdf.parse(data);//轉換爲Date類型 這裏要拋一個異常
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}