Convert the time to the specified format
Date date = new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(simpleDateFormat.format(date));
The date time format before
conversion is converted to yyyy-MM-dd HH:mm:ss time format
To convert the time format to another time format, just modify the time format yyyy-MM-dd HH:mm:ss in SimpleDateFormat to the time format you need,
such as:
ddmmyyyy
dd/mm/yyyy
mm/dd/yyyy
dd -mm-yyyy
mm-dd-yyyy
Month dd yyyy