The time format entered is as follows: 2016.04.12 12:32:55:
To get a date in a certain format, the method of time
1String startstring = "2016.04.25 12:25:44"2SimpleDateFormat SF1 =NewSimpleDateFormat ("Yyyy-mm-dd HH:mm:ss");3SimpleDateFormat SF2 =NewSimpleDateFormat ("Yyyy-mm-dd hh:mm:ss");4Date date1 =Sf1.parse (startstring);5Date Date2 =Sf2.parse (startstring);6String timeString1 =Sf1.format (date1);7String timeString2 =Sf2.format (date2);8 System.out.printIn (timeString1);9System.out.printIn (TIMESTRING2);
The output results are: 2016-04-25 12:25:44
2016-04-25 00:25:44
The output shows that the format is 12 hours if it is hh, and HH is a 24-hour system.
If you just want to get a specific time-hour minute, the method is:
String startstring = "2016.04.25 12:25:44"new SimpleDateFormat ("Yyyy-mm-dd HH:mm:ss"= = Dateformat.format ("hh:mm", Date1) . toString (); System.out.printIn (STARTT);
The output is: 12:25
Java time Formatting (2016.04.12 12:32:55)