Here I have a function that formats a string to a LocalDateTime and returns it.
val dateSentFormatted = timeFormatted(record.data.dateTime);
private fun timeFormatted(dateEmailSent: String?): LocalDateTime {
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd:HH:mm:ss");
return LocalDateTime.parse(dateEmailSent, formatter);
}
My question is I wanted an if statement to run on it elsewhere in my file to check whether it's null as in:
if (!dateSentFormatted != null ) {
}
But it doesn't like that, how else can I check whether a variable of type LocalDateTime is empty in an if statement?
Aucun commentaire:
Enregistrer un commentaire