我希望知道如何编写一个方法来获取最接近指定日期的日期。我的意思是类似以下内容:
public Date getNearestDate(List<Date> dates, Date currentDate) {
return closestDate // The date that is the closest to the currentDate;
}
我找到了类似的问题,但只有一个问题得到了很好的回答,而且代码一直给我NullPointerExceptions错误... 有人能帮助我吗?