public static Long convertToTimestamp(String time, String format) {
    SimpleDateFormat dateFormat = new SimpleDateFormat(format);
    try {
      Date date = dateFormat.parse(time);
      return date.getTime();
    } catch (ParseException e) {
      e.printStackTrace();
    }
    return null;
  }
Convert time in given format to milliseconds
@return
ambari-server/src/main/java/org/apache/ambari/server/utils/DateUtils.java