Java Day of getIntervalDate(String date, int intervalDays)

Here you can find the source of getIntervalDate(String date, int intervalDays)

Description

get Interval Date

License

Open Source License

Declaration

public static synchronized String getIntervalDate(String date, int intervalDays) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    private static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");

    public static synchronized String getIntervalDate(String date, int intervalDays) {
        Calendar cal = Calendar.getInstance();
        int year = Integer.parseInt(String.valueOf(date).substring(0, 4));
        int month = Integer.parseInt(String.valueOf(date).substring(4, 6));
        int day = Integer.parseInt(String.valueOf(date).substring(6, 8));
        cal.set(Calendar.YEAR, year);
        cal.set(Calendar.MONTH, month - 1);
        cal.set(Calendar.DAY_OF_MONTH, day);
        cal.add(Calendar.DATE, intervalDays);

        return dateFormat.format(new Date(cal.getTimeInMillis()));
    }//from   w w  w  .  ja v  a2  s. c  o m
}

Related

  1. getFirstTimeInDay(Date day)
  2. getFormattedNowDatePlusDays(int days, String dateFormat)
  3. getFullAge(Date birthday)
  4. getIncrementDaysSecond(String strDate, int sec)
  5. getInsertDayDate(int days)
  6. getIntervalDays(Date fDate, Date oDate)
  7. getIntevalDays(String startDate, String endDate)
  8. getLateInTheDay(Date date)
  9. getLatest7Day()