1. Learn
  2. /
  3. Courses
  4. /
  5. Input/Output and Streams in Java

Connected

Exercise

Calculate subscription expiration

Subscription services regularly need to calculate expiration dates for users. In this exercise, you'll create a custom method that calculates a user's subscription expiry date based on their subscription period.

All the required classes from java.time have been imported for you.

Instructions

100 XP
  • Define method calculateExpiration() taking a LocalDate and an integer for subscription length in days.
  • Calculate the expiration date by adding the current date and days.
  • Call the calculateExpiration() method with today's date and subscription of 60 days.