java string 转化为date

用SimpleDateFormat来转换 String转Date

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = sdf.parse("1999-09-09 12:09:12");

Date 转 String
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String strDate = sdf.format(d);

原文地址:https://www.cnblogs.com/kaka666/p/9156655.html