String name1 = ((File)obj1).getName();
String name2 = ((File)obj2).getName();
if (name1 == null || name2 == null)
return 0;
//Log Files are in the format server.log_yyyy-mm-ddThh-mm-ss
int name1DateBeginIndex = name1.indexOf
(Constants.FILENAME_DATE_SEPARATOR) + 1;
int name2DateBeginIndex = name2.indexOf
(Constants.FILENAME_DATE_SEPARATOR) + 1;
// obj1 represents server.log i.e latest file
if (name1DateBeginIndex <= 0) {
return 1;
}
// obj2 represents server.log i.e latest file
if(name2DateBeginIndex <= 0) {
return -1;
}
try {
Date name1Date = dateFormat.parse
(name1.substring
(name1DateBeginIndex,name1DateBeginIndex +
Constants.ENTRY_DATE_LENGTH));
Date name2Date = dateFormat.parse
(name2.substring
(name2DateBeginIndex,name1DateBeginIndex +
Constants.ENTRY_DATE_LENGTH));
if (name1Date.after(name2Date))
return 1;
else
return -1;
} catch (ParseException exc) {
return 0;
}