Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
import java.text.ParseException;
import java.time.LocalDate;
import java.time.Period;

try {
    LocalDate birthDate = LocalDate.parse(value);
    LocalDate currentDate = LocalDate.now();
    
    Period dateDiff = Period.between(birthDate, currentDate);
    
    return dateDiff.getYears() + " YEAR(s) & " + dateDiff.getMonths() + " MONTH(s)";
} catch (ParseException e) {
    e.printStackTrace();
}

To quickly see how this script works, feel free to try this sample app below:

APP_beanshellformatter_calculation-SAMPLE.jwa