DateTime dt1 = DateTime.parse("2021-12-23 11:47:00");
DateTime dt2 = DateTime.parse("2018-02-27 10:09:00");
if(dt1.compareTo(dt2) == 0){
print("Both date time are at same moment.");
}
if(dt1.compareTo(dt2) < 0){
print("DT1 is before DT2");
}
if(dt1.compareTo(dt2) > 0){
print("DT1 is after DT2");
}