I'm getting values like the next from an API "2022-01-01T00:00:00.000+02:00" and I want to do a validator for dates, to check if the timestamp received is valid or not in the future.
I'm reading about SimpleDateFormat, but I don't know if this is the best way to do that in kotlin.
In java I would do like this:
public static boolean isValidDate(String inDate) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss:ms");
dateFormat.setLenient(false);
try {
dateFormat.parse(inDate.trim());
} catch (ParseException pe) {
return false;
}
return true;
}
Thank you