24小时内的总分钟数为1440。因此,当差异小于零(但您需要一个正数)时,则应在结果中加一整天:
int diff = MINUTES.between(arrival, a);if (diff < 0) { diff += 1440;}
您可以使用以下方法实现相同的目的:
int diff = (MINUTES.between(arrival, a) + 1440) % 1440;
欢迎分享,转载请注明来源:内存溢出
24小时内的总分钟数为1440。因此,当差异小于零(但您需要一个正数)时,则应在结果中加一整天:
int diff = MINUTES.between(arrival, a);if (diff < 0) { diff += 1440;}
您可以使用以下方法实现相同的目的:
int diff = (MINUTES.between(arrival, a) + 1440) % 1440;
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)