1、日期转换成字符串
Date da = new Date();
String dd = df.format(da);
System.out.println(dd);
2、字符转换成日期
String s1 = "Tue Aug 26 16:50:51 CST 2014";
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
DateFormat df2 = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy",java.util.Locale.ENGLISH);
Date d1 = df2.parse(s1);
String ss = df.format(d1);
System.out.println(ss);
String s2 = "Tue Aug 26 16:50:51 CST 2014";
Date d2 = new Date(s2);
String sss = df.format(d2);
System.out.println(sss);
时间: 2024-11-05 02:24:28