Java Today getStartOfDayRelative(int daysFromToday)

Here you can find the source of getStartOfDayRelative(int daysFromToday)

Description

get Start Of Day Relative

License

Apache License

Declaration

public static Calendar getStartOfDayRelative(int daysFromToday) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {
    /**//from w ww . ja v  a 2  s .  c o  m
     * 1 hour, represented as millis
     */
    public static final long HOUR = (1000 * 60) * 60;
    /**
     * 1 minute, represented as millis
     */
    public static final long MINUTE = 1000 * 60;
    /**
     * 1 second, represented as millis
     */
    public static final long SECOND = 1000;

    public static Calendar getStartOfDayRelative(int daysFromToday) {
        Calendar rtn = getBeginningOfDay();
        rtn.add(Calendar.DATE, daysFromToday);
        return rtn;
    }

    /**
     * Returns a date of the beginning of today.
     *
     * @return beginning of today
     */
    public static Calendar getBeginningOfDay() {
        Calendar today = new GregorianCalendar();
        today.set(Calendar.HOUR, 0);
        today.set(Calendar.MINUTE, 0);
        today.set(Calendar.SECOND, 0);
        today.set(Calendar.MILLISECOND, 0);

        return today;
    }
}

Related

  1. getEndOfToday()
  2. getFirstDate(Date today)
  3. getLastCalendarOfToday()
  4. getNDaysFromToday(int n)
  5. getSomedayAfterToday(int x)
  6. getStartOfToday()
  7. getStartOfToday()
  8. getStringToday()
  9. getTimeNumberToday()