比如我要把“2016-01-13 10:09:24”轉換成“2016/01/13”的字符串
public static void main(String[] args) {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String date1 = "2016-01-13 10:09:24";
try {
Date dt1 = df.parse(date1);
DateFormat fmt = new SimpleDateFormat("yyyy/MM/dd");
String date=fmt.format(dt1);
System.out.println(date);
}catch(Exception e){
}
}