我需要使用Java更改日期格式
dd/MM/yyyy to yyyy/MM/dd
如何使用SimpleDateFormat从一种日期格式转换为另一种日期格式:
SimpleDateFormat
final String OLD_FORMAT = "dd/MM/yyyy"; final String NEW_FORMAT = "yyyy/MM/dd"; // August 12, 2010 String oldDateString = "12/08/2010"; String newDateString; SimpleDateFormat sdf = new SimpleDateFormat(OLD_FORMAT); Date d = sdf.parse(oldDateString); sdf.applyPattern(NEW_FORMAT); newDateString = sdf.format(d);