问题展示:想要去除多余显示只显示(时分秒:23:59:59)
解决办法:
问题解决
实现代码:
String dateString = "2023-07-11 23:59:59";
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat outputFormat = new SimpleDateFormat("HH:mm:ss");
Date date = null;
try {
date = inputFormat.parse(dateString);
} catch (java.text.ParseException e) {
e.printStackTrace();
}
String timeOnly = outputFormat.format(date);
System.out.println(timeOnly);