forked from zfman/AlgorithmCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShenCe2.java
More file actions
38 lines (36 loc) · 1.07 KB
/
Copy pathShenCe2.java
File metadata and controls
38 lines (36 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package other;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
/**
* 神策数据
* 输入两行,第一行为时钟,第二行是经过的时间,输入时钟显示的结果
*
* 输入:
* 10:00:00
* 00:11:12
*
* 输出:
* 10:11:12
*
*/
public class ShenCe2 {
public static void main(String[] args){
Scanner scanner=new Scanner(System.in);
String line1=scanner.nextLine();
String line2=scanner.nextLine();
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat sdf2=new SimpleDateFormat("HH:mm:ss");
try {
Date date1=sdf.parse("2018-09-21 "+line1);
Date date2=sdf.parse("2018-09-21 "+line2);
Date date3=sdf.parse("2018-09-21 00:00:00");
Date date4=new Date(date1.getTime()+(date2.getTime()-date3.getTime()));
String ret=sdf2.format(date4);
System.out.println(ret);
} catch (ParseException e) {
e.printStackTrace();
}
}
}