public List pageList(List resList, int page, int limit) {
List resultList = null;
if (resList != null && resList.size() != 0) {
if (page != 0 && limit != 0) {
Integer count = resList.size();
Integer pageCount = 0;
if (count % limit == 0) {
pageCount = count / limit;
} else {
pageCount = count / limit + 1;
}
int fromIndex = 0;
int toIndex = 0;
if (page != pageCount) {
fromIndex = (page - 1) * limit;
toIndex = fromIndex + limit;
} else {
fromIndex = (page - 1) * limit;
toIndex = count;
}
resultList = resList.subList(fromIndex, toIndex);
} else {
resultList = resList;
}
}
return resultList;
}