Java Day Compare afterNDaysDate(String theDate, int nDayNum, String format)

Here you can find the source of afterNDaysDate(String theDate, int nDayNum, String format)

Description

after N Days Date

License

Apache License

Declaration

public static String afterNDaysDate(String theDate, int nDayNum, String format) throws ParseException 

Method Source Code

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

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

import java.util.TimeZone;

public class Main {

    public static String afterNDaysDate(String theDate, int nDayNum, String format) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat(format);
        Date dd1 = sdf.parse(theDate);
        Calendar cal = Calendar.getInstance();
        cal.setTime(dd1);/*from  ww  w . j  a  va2  s  .co m*/
        cal.add(Calendar.DAY_OF_YEAR, nDayNum);
        sdf.setTimeZone(TimeZone.getDefault());
        return (sdf.format(cal.getTime()));
    }
}

Related

  1. afterNDay(int n)
  2. compareDateByDay(Date date1, Date date2)
  3. compareDay(Date first, Date second)
  4. compareInSameDay(Date date1, Date date2)
  5. isSameDay(Date a, Date b)