Android examples for java.util:Date Compare
Compare two Date value in string of yyyy-MM-dd format
import android.text.TextUtils; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.StringTokenizer; import java.util.regex.Pattern; public class Main{ public static long determineDate(String a, String b) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); long daysBetween = 0; try {/*from ww w . j a v a 2 s . c o m*/ Date d1 = sdf.parse(a); Date d2 = sdf.parse(b); daysBetween = (d2.getTime() - d1.getTime() + 1000000) / (3600 * 24 * 1000); ; } catch (Exception e) { } return daysBetween; } }