List of utility methods to do Date Compare
int | compareDate(Date first, Date second) compare Date Calendar cf = Calendar.getInstance(); cf.setTime(first); Calendar cs = Calendar.getInstance(); cs.setTime(second); if (cf.after(cs)) { return 1; return cf.before(cs) ? -1 : 0; ... |
long | compareDate(Date sourceDate, Date targetDate) compare Date long ret = -1; if (sourceDate == null && targetDate == null) { ret = 0; } else if (sourceDate == null) { ret = -1; } else if (targetDate == null) { ret = 1; } else { ... |
long | compareDate(Date start, Date end) compare Date long temp = 0; Calendar starts = Calendar.getInstance(); Calendar ends = Calendar.getInstance(); starts.setTime(start); ends.setTime(end); temp = ends.getTime().getTime() - starts.getTime().getTime(); return temp; |
boolean | compareDate(String begingDate, String endDate, String format) compare Date boolean boo = true; Date begin = null; Date end = null; if (format.isEmpty()) { format = format = "yyyy/MM/dd"; DateFormat df = new SimpleDateFormat(format); if (null == begingDate || "".equals(begingDate)) { ... |
int | compareDate(String d1, String d2) Compare date int. short vl = 1; GregorianCalendar gc = new GregorianCalendar(); gc.setTime(getStrDate(d1)); int year = gc.get(GregorianCalendar.YEAR); int month = gc.get(GregorianCalendar.MONTH); int day = gc.get(GregorianCalendar.DAY_OF_MONTH); gc.setTime(getStrDate(d2)); int tempYear = gc.get(GregorianCalendar.YEAR); ... |
int | compareDate(String d1, String d2) compare Date if (d1.trim().length() > 10) { d1 = d1.split(" ")[0]; if (d2.trim().length() > 10) { d2 = d2.split(" ")[0]; GregorianCalendar date1 = new GregorianCalendar(); String[] temp1 = d1.split("-"); ... |
boolean | compareDate(String date) compare Date Date d = new Date(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); String dateNowStr = df.format(d); try { Date dt1 = df.parse(date); Date dt2 = df.parse(dateNowStr); if (dt1.getTime() > dt2.getTime()) { return true; ... |
int | compareDate(String date0, String date1) compare Date SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy"); try { Date dt0 = sdf.parse(date0); Date dt1 = sdf.parse(date1); return dt0.compareTo(dt1); } catch (Exception ex) { ex.printStackTrace(); return 1; ... |
int | compareDate(String date1, File file) compare Date long d1; if (!isNumeric(date1)) d1 = stringToLong(date1) + 1000; else d1 = Long.parseLong(date1); long d2 = file.lastModified(); if (d1 == d2) return 0; ... |
boolean | compareDate(String DATE1, String DATE2) compare Date DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm"); boolean compareFlag = false; try { Date dt1 = df.parse(DATE1); Date dt2 = df.parse(DATE2); if (dt1.getTime() > dt2.getTime()) { compareFlag = true; } else if (dt1.getTime() < dt2.getTime()) { ... |