Java Utililty Methods Minute Calculate

List of utility methods to do Minute Calculate

Description

The list of methods to do Minute Calculate are organized into topic(s).

Method

StringaddOrRemoveMinutes(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());
booleancompareDateEndWithMinute(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));
StringcountTimeAfter(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);
longdiffOfMinutes(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);
StringformatDateMinutes(Date myDate, String pattern)
format Date Minutes
return formatDateTime(myDate, pattern);
intgetAlarmMinutes(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);
...
StringgetCurrCustomMinuteDate(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);
StringgetForwardTimeByMinute(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());
StringgetFutureDate(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());
longgetIntevalMinutes(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);
...