public static long getTimeInMillis(String time) {
        Integer secs = DateUtils.secondsPastMidnight(time);
        if (secs == null) {
            secs = 0;
            try {
                int isPM = 0;

                String[] t = time.split("[\\W]+");
                if (t.length >= 3 && t[2].trim().equalsIgnoreCase("PM"))
                    isPM = 12;

                secs = (Integer.valueOf(t[0]) + isPM) * 60 * 60; // hours
                secs += Integer.valueOf(t[1]) * 60; // minutes in seconds
            } catch (Exception _) {
            }
        }

        return secs * 1000; // milliseconds
    }