-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewer_than.groovy
43 lines (40 loc) · 1.28 KB
/
newer_than.groovy
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
39
40
41
42
import java.util.Date;
import java.util.Scanner;
public class NewerThan {
public static void main(String[] args) {
long threshold = Long.parseLong(args[0]);
if (threshold < 9999999999L) {
threshold = threshold * 1000;
}
String line;
Scanner stdin = new Scanner(System.in);
while (stdin.hasNextLine() && !(line = stdin.nextLine()).equals("")) {
String[] tokens = line.split("::");
if (tokens.length != 3) {
System.err.println("bad line: " + line);
continue;
}
//System.err.println("NewerThan.main()" + line);
try {
Long l = Long.parseLong(tokens[2]);
if (l < 9999999999L) {
l = l * 1000;
}
long difference = l - threshold;
// System.out.println("NewerThan.main() --------------------------");
if (l > threshold) {
System.out.println(line);
System.err.println("NewerThan.main() new: " + new Date(l));
} else {
// System.out.println("NewerThan.main() l = " + l);
// System.out.println("NewerThan.main() threshold = " + threshold);
// System.err.println("NewerThan.main() too old: " + new Date(l));
}
//System.out.println("NewerThan.main() difference = " + difference);
} catch (Exception e) {
System.err.println("NewerThan.main() " + e + ": " + line);
}
}
stdin.close();
}
}