Verify if a date is after another one

Verify dates is something that many java starters have doubts. Often they get an own solution to the problem when there is no need.

See what the java.util.Date can do for us:

public void verifyDates(String strCompareDate)
    SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");

    Date date = new Date();
    Date compareDate = null;

        compareDate = format.parse(strCompareDate);
    catch (ParseException p){p.printStackTrace();}

        // do something

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s