Java tutorial
package com.its.web.services; import java.util.Calendar; import java.util.Date; import org.joda.time.DateTime; import org.joda.time.Days; import org.springframework.stereotype.Service; import com.its.web.db.mappings.License; @Service public class DatesService { public boolean isTrialLicenseStilValid(License license) { int remainingDays = getRemainingDays(license); if (remainingDays >= 0) { return true; } else { return false; } } public int getRemainingDays(License license) { Date now = new Date(); Calendar c = Calendar.getInstance(); c.setTime(license.getStartDate()); c.add(Calendar.DATE, license.getTrialPeriod()); Date endTrialDate = c.getTime(); int remainingDays = Days.daysBetween(new DateTime(now), new DateTime(endTrialDate)).getDays(); return remainingDays; } }