Java Day of getFormattedNowDatePlusDays(int days, String dateFormat)

Here you can find the source of getFormattedNowDatePlusDays(int days, String dateFormat)

Description

get Formatted Now Date Plus Days

License

Apache License

Declaration

public static String getFormattedNowDatePlusDays(int days, String dateFormat) 

Method Source Code


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

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {
    public static String getFormattedNowDatePlusDays(int days, String dateFormat) {
        Date nowDate = getNowDate();
        Date futureDate = addDaysToDate(nowDate, days);
        return dateToString(futureDate, dateFormat);
    }//w  w w .  ja v  a2s . c om

    public static Date getNowDate() {
        return Calendar.getInstance().getTime();
    }

    private static Date addDaysToDate(Date date, int daysCount) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.DATE, daysCount);
        return calendar.getTime();
    }

    private static String dateToString(Date date, String format) {
        DateFormat dateFormat = new SimpleDateFormat(format);
        return dateFormat.format(date);
    }
}

Related

  1. getFirstDay(Date date)
  2. getFirstDayInThisQuarter(String nowDate)
  3. getFirstDayOfQuarter(Date date)
  4. getFirstOfDay(Date date)
  5. getFirstTimeInDay(Date day)
  6. getFullAge(Date birthday)
  7. getIncrementDaysSecond(String strDate, int sec)
  8. getInsertDayDate(int days)
  9. getIntervalDate(String date, int intervalDays)