Looking for a kotlin logic

Job ID: 34648901

Budget: $10 – $30 CAD

Looking a logic for calculating end date.
If a customer subscribes on September 14, cancels anywhere from September 14 to October 13. End date should be October 14 only.

Taking the example, if the customer cancels after october 14, end date should be November 14.