第1个回答 2017-07-14
//24小时制
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//12小时制
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String date1 = "2017-04-23 16:45:12";
try {
sdf.parse(date1);
System.out.println(sdf.format(sdf.parse(date1))); //2017-04-23 16:45:12
System.out.println(sdf1.format(sdf.parse(date1))); //2017-04-23 04:45:12
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}本回答被提问者采纳