public static void main(String[] args) throws ParseException { String time = "2019-3-13 9:0:0"; SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date date = simpleDateFormat.parse(time); SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String str = sdf2.format(date); System.out.println(str); }
输出结果为:2019-3-13 9:00:00