19 package org.sleuthkit.autopsy.datasourceprocessors.xry;
 
   21 import java.time.Instant;
 
   22 import java.time.LocalDateTime;
 
   23 import java.time.OffsetDateTime;
 
   24 import java.time.ZoneId;
 
   25 import java.time.ZonedDateTime;
 
   26 import java.time.format.DateTimeFormatter;
 
   27 import java.time.temporal.TemporalAccessor;
 
   28 import java.time.temporal.TemporalQueries;
 
   30 import org.
sleuthkit.datamodel.InvalidAccountIDException;
 
   35 final class XRYUtils {
 
   39     private static final DateTimeFormatter DATE_TIME_PARSER
 
   40             = DateTimeFormatter.ofPattern(
"[(XXX) ][O ][(O) ]a h:m:s M/d/y");
 
   42     private static final String DEVICE_LOCALE = 
"(device)";
 
   43     private static final String NETWORK_LOCALE = 
"(network)";
 
   45     public static boolean isPhoneValid(String phoneNumber) {
 
   47             CommunicationsUtils.normalizePhoneNum(phoneNumber);
 
   49         } 
catch (InvalidAccountIDException ex) {
 
   54     public static boolean isEmailValid(String email) {
 
   56             CommunicationsUtils.normalizeEmailAddress(email);
 
   58         } 
catch (InvalidAccountIDException ex) {
 
   69     public static long calculateSecondsSinceEpoch(String dateTime) {
 
   70         String dateTimeWithoutLocale = removeDateTimeLocale(dateTime).trim();
 
   87         String reversedDateTime = reverseOrderOfDateTimeComponents(dateTimeWithoutLocale);
 
   95         String reversedDateTimeWithGMT = reversedDateTime.replace(
"UTC", 
"GMT");
 
   96         TemporalAccessor result = DATE_TIME_PARSER.parseBest(reversedDateTimeWithGMT,
 
   99                 OffsetDateTime::from);
 
  101         if (result.query(TemporalQueries.zoneId()) == null) {
 
  103             return ZonedDateTime.of(LocalDateTime.from(result),
 
  104                     ZoneId.of(
"GMT")).toEpochSecond();
 
  106             return Instant.from(result).getEpochSecond();
 
  118     private static String reverseOrderOfDateTimeComponents(String dateTime) {
 
  119         StringBuilder reversedDateTime = 
new StringBuilder(dateTime.length());
 
  120         String[] dateTimeComponents = dateTime.split(
" ");
 
  121         for (String component : dateTimeComponents) {
 
  122             reversedDateTime.insert(0, 
" ").insert(0, component);
 
  124         return reversedDateTime.toString().trim();
 
  135     private static String removeDateTimeLocale(String dateTime) {
 
  136         String result = dateTime;
 
  137         int deviceIndex = result.toLowerCase().indexOf(DEVICE_LOCALE);
 
  138         if (deviceIndex != -1) {
 
  139             result = result.substring(0, deviceIndex);
 
  141         int networkIndex = result.toLowerCase().indexOf(NETWORK_LOCALE);
 
  142         if (networkIndex != -1) {
 
  143             result = result.substring(0, networkIndex);