我有三个日期对象 - startDate,endDate,currentDate。它们代表时间间隔的开始/结束和当前日期。如果当前日期在startDate和endDate之间,则我想知道当前日期占时间间隔的百分比(x)。
谢谢!
.getTime()
来计算百分比:double start = (double)StartDate.getTime();
double end = (double)EndDate.getTime();
double cur = (double)CurrentDate.getTime();
double percent = ((cur - start) / (end - start)) * 100f;
编辑:由于这是一个百分比而不是小数,因此添加了* 100f
...