code: public static int toUnix(String time, String pattern) {
          LocalDateTime formatted = LocalDateTime.parse(time, DateTimeFormatter.ofPattern(pattern));
          return (int) formatted.atZone(ZoneId.systemDefault()).toInstant().getEpochSecond();
      }
docs: format string time to unix time
  
  @param time    string date
  @param pattern date format pattern
  @return return unix time