![Date和String类型的相互转换 Date和String类型的相互转换](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
String转Date:
SimpleDateFormat bartDateFormat = new SimpleDateFormat("MM-dd-yyyy");
String dateStringToParse = "9-29-2001";
Date date = bartDateFormat.parse(dateStringToParse);
Date转String:
SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd");
date.format(new Date())