List of utility methods to do Minute Calculate
String | addOrRemoveMinutes(String set, int minutesBeforeSunset) add Or Remove Minutes SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss"); Date d = df.parse(set); Calendar cal = Calendar.getInstance(); cal.setTime(d); cal.add(Calendar.MINUTE, minutesBeforeSunset); return df.format(cal.getTime()); |
boolean | compareDateEndWithMinute(Date d1, Date d2) Compare two date in minute detail. SimpleDateFormat dateFormatEndWithMinute = new SimpleDateFormat("yyyy-MM-dd HH:mm"); String s1 = dateFormatEndWithMinute.format(d1); String s2 = dateFormatEndWithMinute.format(d2); return (s1.equals(s2)); |
String | countTimeAfter(String date, int minute) count Time After SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm"); long ret = sdf.parse(date).getTime() + minute * 60 * 1000; Date now = sdf.parse(date); now.setTime(ret); return sdf.format(now); |
long | diffOfMinutes(String begin, String end) diff Of Minutes SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date beginDate = formatter.parse(begin); Date endDate = formatter.parse(end); return (endDate.getTime() - beginDate.getTime()) / (60 * 1000); |
String | formatDateMinutes(Date myDate, String pattern) format Date Minutes return formatDateTime(myDate, pattern);
|
int | getAlarmMinutes(String dtStart, String dtAlarm, Logger logger) If dtStart and date into Alarm aren't empty, computes the minutes before to start the reminder as dtStart - date alarm = minutes and return it. Date dateStart = null; Date dateAlarm = null; if (dtStart == null || dtStart.equals("") || dtAlarm == null || dtAlarm.equals("")) { return 0; try { SimpleDateFormat formatter = new SimpleDateFormat(); formatter.setTimeZone(TIMEZONE_UTC); ... |
String | getCurrCustomMinuteDate(String formatStr, int changeMinute) get Curr Custom Minute Date Calendar cal = new GregorianCalendar(); cal.setTime(getCurrDate()); cal.add(Calendar.MINUTE, changeMinute); return dateToStr(cal.getTime(), formatStr); |
String | getForwardTimeByMinute(int minute, String format) get Forward Time By Minute if (format == null || "".equals(format)) format = "yyyy-MM-dd HH:mm:ss"; Calendar cal = Calendar.getInstance(); cal.add(Calendar.MINUTE, minute); return new SimpleDateFormat(format).format(cal.getTime()); |
String | getFutureDate(int _minutes) get Future Date SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); Calendar cal = Calendar.getInstance(); cal.set(Calendar.MINUTE, cal.get(Calendar.MINUTE) + _minutes); return dateFormatter.format(cal.getTime()); |
long | getIntevalMinutes(String startDate, String endDate) get Inteval Minutes try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date d1 = sdf.parse(startDate); Date d2 = sdf.parse(endDate); long minute = (d2.getTime() - d1.getTime()) / 1000 / 60; return minute; } catch (Exception ee) { System.out.println(ee); ... |