code: public static String formatDateAsUnixTimestamp(Date date) {
          String timestamp = "";
          try {
              timestamp = Long.toString(date.getTime() / 1000L);
          } catch (Exception e) {
              // ignore; will return empty string
          }
  
          return timestamp;
      }
docs: Convert a Date to a Unix timestamp.
  <br>
  If the date object is null or invalid, this method will return an empty
  String.
  
  @param date the date to convert.
  @return date as a Unix timestamp, represented as a String, or an empty
  String if the date object is invalid.