List of usage examples for java.util Calendar add
public abstract void add(int field, int amount);
From source file:Main.java
public static Calendar setNextMonth(Calendar calendar) { calendar.add(Calendar.MONTH, 1); return calendar; }
From source file:Main.java
public static Calendar setPrevMonth(Calendar calendar) { calendar.add(Calendar.MONTH, -1); return calendar; }
From source file:Main.java
/** * Set the last day of the month// w w w .j a v a 2 s.c o m * @param c Calendar */ public static void setLastDayMonth(Calendar c) { c.add(Calendar.MONTH, 1); c.add(Calendar.DAY_OF_YEAR, -1); }
From source file:Main.java
private static Date getTomorrowMorning4am() { Calendar tomorrow = new GregorianCalendar(); tomorrow.add(Calendar.DATE, fONE_DAY); Calendar result = new GregorianCalendar(tomorrow.get(Calendar.YEAR), tomorrow.get(Calendar.MONTH), tomorrow.get(Calendar.DATE), fFOUR_AM, fZERO_MINUTES); return result.getTime(); }
From source file:Main.java
public static Date addSeconds(Date date, Integer seconds) { Calendar cal = Calendar.getInstance(); cal.setTime(date);/*www. j av a 2s. c o m*/ cal.add(Calendar.SECOND, seconds); return cal.getTime(); }
From source file:Main.java
public static Date addDays(Date date, Integer days) { Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from ww w . j av a 2 s. co m*/ cal.add(Calendar.DAY_OF_MONTH, days); return cal.getTime(); }
From source file:Main.java
public static Calendar getCalendarSetToFirstDayOfNextMonth(Calendar currentMonth) { currentMonth.add(Calendar.MONTH, 1); currentMonth.set(Calendar.DAY_OF_MONTH, currentMonth.getActualMinimum(Calendar.DAY_OF_MONTH)); return currentMonth; }
From source file:Main.java
public static Calendar getCalendarSetToLastDayOfPreviousMonth(Calendar currentMonth) { currentMonth.add(Calendar.MONTH, -1); currentMonth.set(Calendar.DAY_OF_MONTH, currentMonth.getActualMaximum(Calendar.DAY_OF_MONTH)); return currentMonth; }
From source file:Main.java
/** * Add the given amount of days to the given calendar. The changes are reflected in the given * calendar.//from ww w . j av a2s. com * @param calendar The calendar to add the given amount of days to. * @param days The amount of days to be added to the given calendar. Negative values are also * allowed, it will just go back in time. */ public static void addDays(Calendar calendar, int days) { calendar.add(Calendar.DATE, days); }
From source file:Main.java
/** * Add the given amount of hours to the given calendar. The changes are reflected in the given * calendar./*from www. ja v a 2s. co m*/ * @param calendar The calendar to add the given amount of hours to. * @param hours The amount of hours to be added to the given calendar. Negative values are also * allowed, it will just go back in time. */ public static void addHours(Calendar calendar, int hours) { calendar.add(Calendar.HOUR, hours); }