I want to make a java program that takes dates as input and generate another date based on the number of days I will add.
eg:
input date 23/4/2018
number of days: 10
output date: 3/5/2018
I want to make a java program that takes dates as input and generate another date based on the number of days I will add.
eg:
input date 23/4/2018
number of days: 10
output date: 3/5/2018
Note; this is pre java 8 code. for java 8 or newer use LocalDate and Period.
int x= <yournumber of days>
Calendar calendar = Calendar.getInstance();
calendar.setTime(givenDate);
calendar.add(Calendar.DAY, x);
use a switch or if-statements to check wether they are days, months or years. take a look around SO. this question has been answered before.