|
28 | 28 | import javax.management.StandardMBean; |
29 | 29 | import java.time.Instant; |
30 | 30 | import java.time.format.DateTimeFormatter; |
| 31 | +import java.time.format.DateTimeParseException; |
31 | 32 | import java.util.Set; |
32 | 33 | import java.util.regex.Matcher; |
33 | 34 | import java.util.regex.Pattern; |
@@ -71,9 +72,18 @@ public KitInformation getKitInformation() { |
71 | 72 |
|
72 | 73 | Matcher matcher = Pattern.compile("^(?<date>.*) \\(Revision (?<revision>.*) from (?<branch>.*)\\)$").matcher(b); |
73 | 74 | if (matcher.matches()) { |
74 | | - // DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd 'at' HH:mm:ss z"); // from core |
75 | | - DateTimeFormatter isoInstant = DateTimeFormatter.ISO_INSTANT; |
76 | | - Instant timestamp = isoInstant.parse(matcher.group("date"), Instant::from); |
| 75 | + DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd 'at' HH:mm:ss z"); |
| 76 | + String date = matcher.group("date"); |
| 77 | + Instant timestamp; |
| 78 | + try { |
| 79 | + timestamp = dtf.parse(date, Instant::from); |
| 80 | + } catch (DateTimeParseException parsing) { |
| 81 | + try { |
| 82 | + timestamp = DateTimeFormatter.ISO_INSTANT.parse(matcher.group("date"), Instant::from); |
| 83 | + } catch (DateTimeParseException parsing2) { |
| 84 | + timestamp = Instant.ofEpochMilli(0L); |
| 85 | + } |
| 86 | + } |
77 | 87 | return new KitInformation(Version.valueOf(version), matcher.group("revision"), matcher.group("branch"), timestamp); |
78 | 88 | } else { |
79 | 89 | return new KitInformation(Version.valueOf(version), "UNKNOWN", "UNKNOWN", Instant.ofEpochMilli(0L)); |
|
0 commit comments