Home > Back-end >  Java a matter of time, 21 hours turn 12 hours system, the problem is when zero
Java a matter of time, 21 hours turn 12 hours system, the problem is when zero

Time:10-27

Input: the 2020-11-11 00:21:00

Now realize output: 2020/11/11 21 points
12 a.m.
Ask, how to realize 2020/11/11 21 points
0 o 'clock in the morning
New answers, your bosses don't spray, thank you

CodePudding user response:

Well, 0 (24) is not zero o 'clock in the morning, is 0 p.m. at 12 o 'clock

CodePudding user response:

MM - dd yyyy - hh: MM: ss lowercase hh

CodePudding user response:

The
refer to the original poster m0_48036920 response:
input: the 2020-11-11 00:21:00

Now realize output: 2020/11/11 21 points
12 a.m.
Ask, how to realize 2020/11/11 21 points
0 o 'clock in the morning
New answers, your bosses don't spray, thank you


 
Public static void main (String [] args) {
//TODO Auto - generated method stub
String STR="2020-11-11 00:21:00";
SimpleDateFormat format=new SimpleDateFormat (" yyyy - MM - dd HH: MM: ss ");
SimpleDateFormat format12=new SimpleDateFormat (" yyyy - MM - dd hh: MM: ss ");
Try {
The Date the Date=format. The parse (STR);
System. The out. Println (date);
System. The out. Println (format12. The format (date));
} the catch (ParseException e) {
//TODO Auto - generated the catch block,
e.printStackTrace();
}
}
  • Related