String型別轉為date型別
public static void main(String[] args) {
SimpleDateFormat sdf_1 = new SimpleDateFormat("yyyyMMdd");
SimpleDateFormat sdf_2 = new SimpleDateFormat("yyyy/MM/dd");
String str = "";
try {
str = sdf_2.format(sdf_1.parse("20110202"));
} catch (ParseException e) {
System.err.println(e.getMessage());
}
System.out.println(str);
}