Date date = new Date();
System.out.println("前:" + date.toLocaleString());
SimpleDateFormat sdf = (SimpleDateFormat) DateFormat.getDateTimeInstance(); 
System.out.println("后:" + sdf.format(date));

代码在线运行:https://tool.lu/coderunner/