Java Date Compare compareDateSequence(String startDate, String endDate)

Here you can find the source of compareDateSequence(String startDate, String endDate)

Description

compare Date Sequence

License

Open Source License

Declaration

public static int compareDateSequence(String startDate, String endDate) 

Method Source Code

//package com.java2s;
/*/*from   w w w  . jav  a 2 s .co m*/
 * ==================================================================
 * The Huateng Software License
 *
 * Copyright (c) 2008-2012 TOPSCF  All rights reserved.
 * ==================================================================
 */

import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static int compareDateSequence(String startDate, String endDate) {
        java.util.Date start_Date = numberToDate(startDate);
        java.util.Date end_Date = numberToDate(endDate);
        int result = start_Date.compareTo(end_Date);
        return result;
    }

    public static Date numberToDate(String dateString) {

        if ("".equals(dateString) || dateString == null) {
            return null;
        }
        Date date = null;
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
        try {
            date = simpleDateFormat.parse(dateString);
        } catch (ParseException e) {
            e.printStackTrace();
            System.out.println("------SCFDataFormat>>StringTodate error="
                    + e);
        }
        return date;
    }
}

Related

  1. compareDateForSecond(Date src, Date target, int second)
  2. compareDates(Date date1, Date date2)
  3. compareDates(Date date1, Date date2)
  4. compareDates(final Date dateA, final Date dateB)
  5. compareDates(final String format, final Date date1, final Date date2)
  6. compareDatesOnly(long date1, long date2)
  7. compareDateTimeNull(Date d1, Date d2)
  8. compareDay(Date date, Date anotherDate)
  9. compareDay(Date date1, int compday)