Get specify minutes back form given date.

@param minutesBack how many minutes want to be back.
@param date date to be handled.
@return a new Date object.
494100
public static Date getDateOfMinutesBack(final int minutesBack, final Date date) {

    return dateBack(Calendar.MINUTE, minutesBack, date);
  }
452924
public static Date getDateEnd(Date date){
        Calendar   ca   =   Calendar.getInstance();
        ca.setTime(date);
        ca.set(Calendar.HOUR, 23);
        ca.set(Calendar.MINUTE, 59);
        ca.set(Calendar.SECOND, 59);
        return  ca.getTime();
    }
814531
def backdate(res, date=None, as_datetime=False, fmt='%Y-%m-%d'):
    
    if res is None:
        return None

    if date is None:
        date = datetime.datetime.now()
    else:
        try:
            date = parse_date(date)
        except Exception as e:
            pass

    new_date = date

    periods = int("".join([s for s in res if s.isdigit()]))

    if periods > 0:

        if "K" in res:
            new_date = date - datetime.timedelta(microseconds=periods)
        elif "S" in res:
            new_date = date - datetime.timedelta(seconds=periods)
        elif "T" in res:
            new_date = date - datetime.timedelta(minutes=periods)
        elif "H" in res or "V" in res:
            new_date = date - datetime.timedelta(hours=periods)
        elif "W" in res:
            new_date = date - datetime.timedelta(weeks=periods)
        else:  # days
            new_date = date - datetime.timedelta(days=periods)

        # not a week day:
        while new_date.weekday() > 4:  # Mon-Fri are 0-4
            new_date = backdate(res="1D", date=new_date, as_datetime=True)

    if as_datetime:
        return new_date

    return new_date.strftime(fmt)
743384
public static Date getStartOfWeek(Date date) {

        if (date == null)
            return null;

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.setFirstDayOfWeek(FIRST_DAY_OF_WEEK);
        calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);

        return calendar.getTime();
    }
1265007
public Date getDateBetween(final Date minDate, final Date maxDate) {
    // this can break if seconds is an int
    long seconds = (maxDate.getTime() - minDate.getTime()) / 1000;
    seconds = (long) (random.nextDouble() * seconds);
    Date result = new Date();
    result.setTime(minDate.getTime() + (seconds * 1000));
    return result;
  }
935134
public static int getMonthFromDate(Date date) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		return cal.get(Calendar.MONTH) + 1;
	}
214906
public static Date addMinutes(final Date date, final int addMinutes)
	{
		final Calendar dateOnCalendar = Calendar.getInstance();
		dateOnCalendar.setTime(date);
		dateOnCalendar.add(Calendar.MINUTE, addMinutes);
		return dateOnCalendar.getTime();
	}
699193
public static Date addHours(final Date date, final int addHours)
	{
		final Calendar dateOnCalendar = Calendar.getInstance();
		dateOnCalendar.setTime(date);
		dateOnCalendar.add(Calendar.HOUR, addHours);
		return dateOnCalendar.getTime();
	}
355128
public B timerWithDate(String timerDate) {
    TimeDate timeDate = createInstance(TimeDate.class);
    timeDate.setTextContent(timerDate);

    TimerEventDefinition timerEventDefinition = createInstance(TimerEventDefinition.class);
    timerEventDefinition.setTimeDate(timeDate);

    element.getEventDefinitions().add(timerEventDefinition);

    return myself;
  }
913927
public static Calendar toCalendar(final Date date) {
        final Calendar c = Calendar.getInstance();
        c.setTime(date);
        return c;
    }
109019
public static Date nextMinute(@NotNull final Date date) {
		return DateUtils.ceiling(date, Calendar.MINUTE);
	}
161667
public String getDateTime(Date date) {

        return CmsDateTimeUtil.getDateTime(date, CmsDateTimeUtil.Format.SHORT);
    }
1054319
public static Dater of(String date, DateStyle dateStyle) {
		return from(date).with(dateStyle);
	}
742754
public Date toDate(Object date) {

        Date d = null;
        if (null != date) {
            if (date instanceof Date) {
                d = (Date)date;
            } else if (date instanceof Long) {
                d = new Date(((Long)date).longValue());
            } else {
                try {
                    long l = Long.parseLong(date.toString());
                    d = new Date(l);
                } catch (Exception e) {
                    // do nothing, just let d remain null
                }
            }
        }
        return d;
    }
1363601
public static Date plusSeconds(Date date, int seconds) {
		return plus(date, seconds, DateTimeField.SECONDS);
	}
396882
public static Date nextHour(@NotNull final Date date) {
		return DateUtils.ceiling(date, Calendar.HOUR_OF_DAY);
	}
946616
public static Timestamp of(Date date) {
    return ofTimeMicroseconds(TimeUnit.MILLISECONDS.toMicros(date.getTime()));
  }