-2
即时尝试计算我将如何确定自开始日期(auctionStart)开始经过一定时间(10%)的时间,并将其与当前日期和结束日期(aEnd)。如果在两个日期之间已经过了10%的时间,则返回true
这是我到目前为止的代码,但即时通讯相当多的方法了解这一点。我一直在尝试使用JodaTime。
private Date auctionStart;
private Date aEnd;
public Boolean tenPercentElapsed(){
SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String aucStartString = f.format(auctionStart);
Date aucStart = f.parse(aucStartString);
DateTime currentTime = new DateTime();
DateTime startTime = new DateTime(aucStart);
int m = Minutes.minutesBetween(startTime, currentTime).getMinutes();
double minutes = (double)m;
if(){
return true;
}
return false;
}
您的问题是什么? – tnw
是否有没有使用'java.time' API的原因? –
时间可以用毫秒表示。以开始和结束之间的毫秒数(当前问题使用分钟数;本质上相同)。这是总数。占总数的10%。以毫秒为单位开始 - 电流。比较。 – KevinO