List of utility methods to do Today
boolean | isToday(final Date date) is Today if (date == null) { return false; return !isInPast(date) && !isInFuture(date); |
boolean | isToday(final Date date) is Today final Calendar now = Calendar.getInstance(); final Calendar calendar = Calendar.getInstance(); calendar.setTime(date); now.set(Calendar.HOUR_OF_DAY, 0); now.set(Calendar.MINUTE, 0); now.set(Calendar.SECOND, 0); now.set(Calendar.MILLISECOND, 0); calendar.set(Calendar.HOUR_OF_DAY, 0); ... |
boolean | isToday(int dateInt) is Today Calendar nowCal = GregorianCalendar.getInstance(); nowCal.setTime(new Date()); Calendar compareCal = convertToCal(dateInt); return nowCal.get(Calendar.DAY_OF_MONTH) == compareCal.get(Calendar.DAY_OF_MONTH) && nowCal.get(Calendar.MONTH) == compareCal.get(Calendar.MONTH) && nowCal.get(Calendar.YEAR) == compareCal.get(Calendar.YEAR); |
boolean | isToDay(long millis) is To Day Calendar now = Calendar.getInstance(); Calendar compare = Calendar.getInstance(); compare.setTimeInMillis(millis); if (now.get(Calendar.YEAR) != compare.get(Calendar.YEAR)) return false; if (now.get(Calendar.DAY_OF_YEAR) != compare.get(Calendar.DAY_OF_YEAR)) return false; return true; ... |
boolean | isToday(long milliseconds) is Today Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(milliseconds); if (getCurrentMonth() == getMonth(milliseconds) && getCurrentDay() == getDay(milliseconds)) { return true; return false; |
boolean | isToday(long timestamp) is Today Calendar calendar = Calendar.getInstance(); int date = calendar.get(Calendar.DATE); int month = calendar.get(Calendar.MONTH); int year = calendar.get(Calendar.YEAR); calendar.setTimeInMillis(timestamp); int _date = calendar.get(Calendar.DATE); int _month = calendar.get(Calendar.MONTH); int _year = calendar.get(Calendar.YEAR); ... |
boolean | isToday(String depDateTime) Is a dateTime today boolean isToday = false; Calendar depDate = parseCalendarString(depDateTime); int depDay = depDate.get(Calendar.DAY_OF_MONTH); Calendar now = getTimeNow(); int nowDay = now.get(Calendar.DAY_OF_MONTH); if (depDay == nowDay) { isToday = true; return isToday; |
boolean | isToday(String sdate) is Today boolean b = false; Date time = toDate(sdate); Date today = new Date(); if (time != null) { String nowDate = dateFormater2.format(today); String timeDate = dateFormater2.format(time); if (nowDate.equals(timeDate)) { b = true; ... |
boolean | isToday(String sdate) is Today boolean b = false; Date time = toDate(sdate); Date today = new Date(); if (time != null) { String nowDate = DATE_FORMATER_2.get().format(today); String timeDate = DATE_FORMATER_2.get().format(time); if (nowDate.equals(timeDate)) { b = true; ... |
String | parseToday(String s) parse Today if (s == null) { return s; Pattern pattern = Pattern.compile("today(?:\\s*\\-\\s*(\\d+))?"); Matcher matcher = pattern.matcher(s); if (!matcher.matches()) { return s; Calendar cal = Calendar.getInstance(); String n = matcher.group(1); if (n != null) { cal.add(Calendar.DATE, -1 * Integer.parseInt(n)); return new SimpleDateFormat("yyyy/MM/dd").format(cal.getTime()); |