String与Date转换
public class TimeTraining {
public static void changeStr(String str){
str = "137878";
}
public static void main(String[] args){
Date cur = new Date();
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String date = ft.format(cur); //format(convert time to string);
System.out.println(date);
try {
Date tdate = ft.parse(date); //format(convert String to time);
System.out.println(tdate);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}