Please share any images or screenshots, if relevant.
Share all details about your problem, including any error messages you may have received.
Hi there, is there a way to compare the value in the “whenChanged” Active Directory attribute against the current date?
For example; if whenCreated is more than 90 days ago from current date, AND lastLoginTimeStamp == null, we can safely disable the account in AD by setting userAccountControl value to 514 as the person therefore never started with the company.
I’m not sure how to utilize the value aggregating in (20190814062704.0Z) to compare against currentDate. Any simple solution?
The code below returns a boolean indicating whether the date of creation is more than 90 days older than today’s date. You can use this boolean value to disable the AD account.
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
String createdTimestamp = "20130225160948.0Z"; // get the value from app attribute
boolean isOlderThan90Days = false;
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss'.0Z'");
try {
Date createdDate = dateFormat.parse(createdTimestamp);
Date currentDate = new Date();
// Calculate the date 90 days ago
Calendar calendar = Calendar.getInstance();
calendar.setTime(currentDate);
calendar.add(Calendar.DAY_OF_MONTH, -90);
Date date90DaysAgo = calendar.getTime();
// Check if the created date is older than 90 days
isOlderThan90Days = createdDate.before(date90DaysAgo);
} catch (ParseException e) {
e.printStackTrace();
}