Java Today getSomedayAfterToday(int x)

Here you can find the source of getSomedayAfterToday(int x)

Description

get Someday After Today

License

LGPL

Declaration

public static Date getSomedayAfterToday(int x) 

Method Source Code

//package com.java2s;
/*/*from  w w  w  .j av  a  2  s  .  c o  m*/
* Distributable under LGPL v3 license.
* See terms of license at https://github.com/Yunfeng/schotel/blob/master/LICENSE
*/

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static Date getSomedayAfterToday(int x) {
        Calendar c = Calendar.getInstance();
        //c.clear(Calendar.HOUR_OF_DAY);
        c.set(Calendar.HOUR_OF_DAY, 0);
        c.clear(Calendar.MINUTE);
        c.clear(Calendar.SECOND);
        c.clear(Calendar.MILLISECOND);
        c.add(Calendar.DAY_OF_MONTH, x);
        return c.getTime();
    }

    public static Date add(Date date, int x) {
        return addDays(date, x);
    }

    public static Date addDays(Date date, int x) {
        Calendar c = Calendar.getInstance();
        c.clear();
        c.setTime(date);
        c.add(Calendar.DATE, x);
        return c.getTime();
    }
}

Related

  1. getCalendarTodayZero(Calendar today)
  2. getEndOfToday()
  3. getFirstDate(Date today)
  4. getLastCalendarOfToday()
  5. getNDaysFromToday(int n)
  6. getStartOfDayRelative(int daysFromToday)
  7. getStartOfToday()
  8. getStartOfToday()
  9. getStringToday()