Java Day of plusDays(Date date, int days)

Here you can find the source of plusDays(Date date, int days)

Description

plus Days

License

Open Source License

Declaration

public static Date plusDays(Date date, int days) 

Method Source Code

//package com.java2s;

import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    private final static SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public static Date plusDays(Date date, int days) {
        if (date == null)
            date = getToday();/*from w  w w. j  a v a 2  s .  c o  m*/
        return changeDays(date, days);
    }

    public static Date getToday() {
        return new Date();
    }

    private static Date changeDays(Date date, int days) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.add(Calendar.DAY_OF_YEAR, days);
        return cal.getTime();
    }

    public static String getTime() {
        return sdfTime.format(new Date());
    }
}

Related

  1. parseDay(int time)
  2. parseDay(String str, String type)
  3. parseDayTime(long ts)
  4. parseFromDays(String date)
  5. plusDay(Date date, int day)
  6. setDays(Date date, int amount)
  7. startOfDay(Date date, String format)
  8. stringSomeDaysAgo(Date currentTime, int days)
  9. strToShortday(String s)