It is necessary to compare data by date, but you can compare by string:
dateFormat = new SimpleDateFormat("dd.MM.yy"); date = dateFormat.parse(dateTime.getDay() + "." + dateTime.getMonth() + "." + dateTime.getYear()); dateFromFile = dateFormat.parse(filename.split(".")[0]); They can be translated into the string, and the date, and both comparisons will be correct. But which comparison will work faster?