Android Date Compare compare(Date date1, Date date2)

Here you can find the source of compare(Date date1, Date date2)

Description

compare

Declaration

public static int compare(Date date1, Date date2) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {
    public static final String VN_DATE_FORMAT = "dd/MM/yyyy";

    public static int compare(Date date1, Date date2) {
        String d1 = dateToString(date1, "yyyyMMdd");
        String d2 = dateToString(date2, "yyyyMMdd");
        return d1.compareTo(d2);
    }/*from  w  ww. j  av a 2s .  co m*/

    public static String dateToString(Date date, String format) {
        if (format == null)
            format = VN_DATE_FORMAT;
        SimpleDateFormat ts = new SimpleDateFormat(format);
        return ts.format(date);
    }
}

Related

  1. dateBeforeDate(Date date, long days)
  2. isSameDay(Date dateSource, Date dateDesti)
  3. isSameInstant(Date date1, Date date2)
  4. needsMidnightCountdown()
  5. dateDiffer(Date date1, Date date2)
  6. compare(String date0, String date1, String format)
  7. isDateTimeAfter(String startDate, String startTime, String endDate, String endTime)
  8. isDateNew(String YearMonthDayHourMinuteSeconds)
  9. isSameDay(Date d1, Date d2)