-3

I want to get next date by putting the any value. like Today is 10/07/2018 when i give input 10 means I have need next date 20/07/2018.

  • 1
    Great! What did you try to solve this problem? Please [edit] your question and include the code you have tried. Does it work? –  Jul 10 '18 at 13:08

1 Answers1

0

Only a few steps are required :

  • take user input
  • take today's date (using Modern Java time API)
  • add to the date the number of days of the input
public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    LocalDate nextDate = nextDate(sc.nextInt());
}

private static LocalDate nextDate(int daysToAdd){
    LocalDate today = LocalDate.now();
    today = today.plusDays(daysToAdd);
    return today;
}

// can be inline in :
// return LocalDate.now().plusDays(int daysToAdd);

Workable Demo

azro
  • 53,056
  • 7
  • 34
  • 70