Font Size:
Ask Joget AI

List Return Status Based on Date

Introduction

In this guide, we will explore how to configure a List to return a specific status based on a date value compared to the current date. This functionality is useful for tracking and displaying statuses such as Expired, Active, or Expiring Soon" based on the value of a date column. This can be achieved using Bean Shell Formatter to evaluate and return the status based on the comparison between the date in the list and the current date.

How does it work?

In this case, we want to return the status Expired or Active based on the date value in the List compared to the actual date. Follow the steps below:

  1. Drag and drop the Expiry Date column, create 2 Expiry Date columns in the list. The first column remains as Expiry Date and the second column, change the label to Status.
  2. On the Status column, go to Formatter and choose BeanShell.
  3. Implement the following Bean Shell scripts to return the appropriate status based on the date value.

Code sample 1: Basic expiration check

This code snippet will return Expired if the date is before today and Active otherwise.

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
 
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
try {
    Date date = formatter.parse(value);
    Calendar cal = Calendar.getInstance();
    if (date.before(cal.getTime())) {
        return "Expired";
    } else {
        return "Active";
    }
} catch (ParseException e) {
    e.printStackTrace();
}

Code sample 2: Expiration check with expiring soon

This code has added logic to show the nearing expiry date with the status Expiring Soon in 30 days.

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
 
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
try {
    Date date = formatter.parse(value);
    Calendar cal = Calendar.getInstance();
     
    if (date.before(cal.getTime())) {
        return "Expired"; //before today = expiried
    }
    cal.add(Calendar.DAY_OF_MONTH, 30); //increase today's date by 30 days
    if (date.before(cal.getTime())) {
        return "Expiring Soon in 30 days"; //between now and next 30 days
    }else{
        return "Active"; //more than 30 days ahead
    }
} catch (ParseException e) {
    e.printStackTrace();
}

Expected outcome

Video Tutorial

Download Sample App

Download the sample app for List Return Status Based on Date
Created by Aadrian Last modified by Nur Baizura Badrul Sham on May 19, 2026