(+84) 236.3827111 ex. 402

Chuyển đổi String ↔ Date với SimpleDateFormat


static Date convertStringToDate(String str) {
try {
return new SimpleDateFormat("dd/MM/yyyy").parse(str);
} catch (ParseException e) {
System.out.println(e.getMessage());
}
return null;
}
static String convertDateToString(Date d) {
return new SimpleDateFormat("dd/MM/yyyy").format(d);
}