android compare 2 dates to find difference
<p>i have a booking form that requires a user to input their details alongside a date.
the user cannot submit a date that is within 24 hours.
a booking must be made after  24 hours.</p>

<p>how can i implement this?.
i have obtained the current date and time.</p>

<p>so if the current date and time is 19062012 1324 the booking cannot be made until 20062012 1324</p>

<p>what i tried to do is this:</p>

<pre><code>long mdates = (long) (Long.parseLong(date.getText().toString()));
    long mprefered= (long) (Long.parseLong(date2.getText().toString()));
        long sub = mprefered - mdates;

    if (preferedDateEditText.getText().toString() != null
            &amp;&amp; !preferedDateEditText.getText().toString()
                    .equalsIgnoreCase("") &amp;&amp; sub&gt;100000000) {
        emailBody += "Prefered date &amp; Time:"
                + preferedDateEditText.getText().toString().trim()
                + "\n sub="+sub;
    } else {
        errorMessage += "A booking cannot be made within 24 hours.";
    }
</code></pre>

<p>this works however if the prefered date is 01072012 1324 then it wont accept as being 24 hours in advance
any help would be appreciated</p>
