-2

I want to get the date 7 days from what the current date is. I am not to sure what code would be needed.

The code I have to find the current date is:

DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
Calendar cal = Calendar.getInstance();
String date = dateFormat.format(cal.getTime());
hurnhu
  • 888
  • 2
  • 11
  • 30
Tyler Bull
  • 33
  • 8

2 Answers2

0

I found the following code on stack overflow.... How can I increment a date by one day in Java?

SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
Calendar cal = Calendar.getInstance();
cal.setTime( dateFormat.parse( inputString ) );
cal.add( Calendar.DATE, 7 );
Community
  • 1
  • 1
hurnhu
  • 888
  • 2
  • 11
  • 30
-2

LocalDateTime.now().plusDays(7)

https://docs.oracle.com/javase/tutorial/datetime/iso/datetime.html

jreancsu
  • 421
  • 5
  • 13