code: private static int convertTimestamp(String timestamp) throws ParseException {
  
          // Get the deadline from timestamp
          int deadline;
          SimpleDateFormat dateFormat = new SimpleDateFormat("hh:mm:ss");
          Date parsedDate;
  
          // Relative timestamp
          if (timestamp.startsWith("+")) {
              parsedDate = dateFormat.parse(timestamp.replace("+", ""));
              Calendar c = Calendar.getInstance();
              c.setTime(parsedDate);
              deadline = c.get(Calendar.SECOND) + c.get(Calendar.MINUTE) * 60 + c.get(Calendar.HOUR_OF_DAY) * 3600;
          }
          // Absolute timestamp
          else {
              Calendar c = Calendar.getInstance();
              c.setTime(new Date());
              Date now = dateFormat.parse(c.get(Calendar.HOUR_OF_DAY)+":"+c.get(Calendar.MINUTE)+":"+c.get(Calendar.SECOND));
              parsedDate = dateFormat.parse(timestamp);
              deadline = (int) ((parsedDate.getTime() - now.getTime()) / 1000);
              if (deadline < 0) {
                  // Timestamp is for tomorrow
                  deadline = (int) ((parsedDate.getTime() + (24 * 3600 * 1000) - now.getTime()) / 1000);
              }
          }
  
          return deadline;
      }
docs: Convert an absolute timestamp (string) to either a relative or an absolute deadline (integer) .
  
  @param timestamp the timestamp to convert
  @return  the deadline
  @throws ParseException if the timestamp string doesn't match the format "hh:mm:ss" for an absolute timestamp
  or "+hh:mm:ss" for relative timestamp