mae*_*sto 3 java datetime android
我有三个日期对象 - startDate,endDate,currentDate.它们代表时间间隔的开始/结束,以及临近日期.我想知道currentDate代表(x)的百分比,如果currentDate在startDate和endDate之间.
谢谢!
您可以.getTime()
在每个日期使用来计算百分比:
double start = (double)StartDate.getTime();
double end = (double)EndDate.getTime();
double cur = (double)CurrentDate.getTime();
double percent = ((cur - start) / (end - start)) * 100f;
Run Code Online (Sandbox Code Playgroud)
编辑:* 100f
因为它是百分比而不是十进制而添加...