List of utility methods to do Date Interval Get
int | getOffectHour(long date1, long date2) get Offect Hour Calendar calendar1 = Calendar.getInstance(); calendar1.setTimeInMillis(date1); Calendar calendar2 = Calendar.getInstance(); calendar2.setTimeInMillis(date2); int h1 = calendar1.get(Calendar.HOUR_OF_DAY); int h2 = calendar2.get(Calendar.HOUR_OF_DAY); int h = 0; int day = getOffectDay(date1, date2); ... |
int | getOffectHour(long date1, long date2) get Offect Hour Calendar calendar1 = Calendar.getInstance(); calendar1.setTimeInMillis(date1); Calendar calendar2 = Calendar.getInstance(); calendar2.setTimeInMillis(date2); int h1 = calendar1.get(Calendar.HOUR_OF_DAY); int h2 = calendar2.get(Calendar.HOUR_OF_DAY); int h = 0; int day = getOffectDay(date1, date2); ... |
int | getOffectMinutes(long date1, long date2) get Offect Minutes Calendar calendar1 = Calendar.getInstance(); calendar1.setTimeInMillis(date1); Calendar calendar2 = Calendar.getInstance(); calendar2.setTimeInMillis(date2); int m1 = calendar1.get(Calendar.MINUTE); int m2 = calendar2.get(Calendar.MINUTE); int h = getOffectHour(date1, date2); int m = 0; ... |
int | getOffectMinutes(long date1, long date2) get Offect Minutes Calendar calendar1 = Calendar.getInstance(); calendar1.setTimeInMillis(date1); Calendar calendar2 = Calendar.getInstance(); calendar2.setTimeInMillis(date2); int m1 = calendar1.get(Calendar.MINUTE); int m2 = calendar2.get(Calendar.MINUTE); int h = getOffectHour(date1, date2); int m = 0; ... |
String | getStringByOffset(Date date, String format, int calendarField, int offset) get String By Offset String strDate = null; try { Calendar c = new GregorianCalendar(); SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat( format); c.setTime(date); c.add(calendarField, offset); strDate = mSimpleDateFormat.format(c.getTime()); ... |
String | getStringByOffset(Date date, String format, int calendarField, int offset) get String By Offset String strDate = null; try { Calendar c = new GregorianCalendar(); SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat( format); c.setTime(date); c.add(calendarField, offset); strDate = mSimpleDateFormat.format(c.getTime()); ... |
String | getStringByOffset(String strDate, String format, int calendarField, int offset) get String By Offset String mDateTime = null; try { Calendar c = new GregorianCalendar(); SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat( format); c.setTime(mSimpleDateFormat.parse(strDate)); c.add(calendarField, offset); mDateTime = mSimpleDateFormat.format(c.getTime()); ... |
String | getStringByOffset(String strDate, String format, int calendarField, int offset) get String By Offset String mDateTime = null; try { Calendar c = new GregorianCalendar(); SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat( format); c.setTime(mSimpleDateFormat.parse(strDate)); c.add(calendarField, offset); mDateTime = mSimpleDateFormat.format(c.getTime()); ... |
int | getDaysSince(Date date) get Days Since if (date == null) { return 0; return (int) ((getCurrentEpochTime() - date.getTime()) / ONE_DAY_IN_MILLIS); |
String | timeAgo(Date d) time Ago final long referenceTime = d.getTime(); final long nowTime = System.currentTimeMillis(); final long diffTime = Math.abs(nowTime - referenceTime); if (diffTime > DateUtils.DAY_IN_MILLIS) { return format(d, "yyyy-MM-dd HH:mm"); } else if (diffTime > DateUtils.HOUR_IN_MILLIS) { return String.format(TIMEAGO_HOURS_AGO, diffTime / DateUtils.HOUR_IN_MILLIS); ... |