Thursday, 10 September 2015

Milliseconds Between

public static long millisecondsBetween(Date firstDate, Date secondDate)
    {
        if (firstDate == null || secondDate == null)
        {
            String msg = "Null parameter passed to DateUtils.hoursBetween";
            throw new IllegalArgumentException(msg);
        }

        long millisecondsBetween = secondDate.getTime() - firstDate.getTime();
        if (millisecondsBetween < 0)
        {
            millisecondsBetween = 0;
        }
        return millisecondsBetween;
    }

No comments:

Post a Comment