Java Date Compare compare(Date start, String end)

Here you can find the source of compare(Date start, String end)

Description

compare

License

Apache License

Declaration

public static Boolean compare(Date start, String end) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Date;

import java.text.SimpleDateFormat;

public class Main {
    public static final String dtLong = "yyyyMMddHHmmss";

    public static Boolean compare(Date start, String end) {
        SimpleDateFormat format = new SimpleDateFormat(dtLong);
        String s1 = format.format(start);
        String s2 = end;//from w  w w . j a  v  a  2 s.c  o m

        java.util.Calendar c1 = java.util.Calendar.getInstance();
        java.util.Calendar c2 = java.util.Calendar.getInstance();

        try {
            c1.setTime(format.parse(s1));
            c2.setTime(format.parse(s2));
        } catch (java.text.ParseException e) {
        }
        int result = c1.compareTo(c2);
        if (result <= 0) {
            return false;
        } else {
            return true;
        }

    }
}

Related

  1. compare(Date d1, Date d2)
  2. compare(Date date, Date fromDate, Date toDate)
  3. compare(Date date1, Date date2, String format)
  4. Compare(Date dtA, Date dtB, boolean bUnkIsPast)
  5. compare(Date start, Date end)
  6. compare(Date startDate, Date endDate, Date targetDate)
  7. compare(final Date lhs, final Date rhs)
  8. compare(final Date one, final Date another)
  9. compare2Date(Date date1, Date date2)