(Object datetime2)
| 75 | |
| 76 | // Returns Long (epoch millis) or null |
| 77 | public static Object parseDate(Object datetime2) { |
| 78 | if (!(datetime2 instanceof String)) { |
| 79 | return null; |
| 80 | } |
| 81 | |
| 82 | String datetime = stripUtcSuffix(((String) datetime2).trim()); |
| 83 | if (datetime.isEmpty()) { |
| 84 | return null; |
| 85 | } |
| 86 | |
| 87 | try { |
| 88 | // ISO 8601 like: 1986-04-26T01:23:47.000Z |
| 89 | if (datetime.indexOf('T') >= 0) { |
| 90 | return Instant.parse(datetime).toEpochMilli(); |
| 91 | } |
| 92 | |
| 93 | // Space format like: 1986-04-26 00:00:00 (treated as UTC) |
| 94 | LocalDateTime ldt = LocalDateTime.parse(datetime, SPACE_FORMAT); |
| 95 | return ldt.toInstant(ZoneOffset.UTC).toEpochMilli(); |
| 96 | |
| 97 | } catch (DateTimeParseException ex) { |
| 98 | return null; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | // public static Long parse8601(Object datetime2) { |
| 103 | // if (!(datetime2 instanceof String)) return null; |
no test coverage detected