//格式化数据 SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String format = sdf.format(new Date()); System.out.println(format);//String格式的数据转化成Date格式 String timeStr = "2019-07-09 03:34:56 "; Date parse = sdf.parse(timeStr); System.out.println(parse);