计算事件之间的天数 - Android [英] Calculate Amount of Days between Events - Android

查看:214
本文介绍了计算事件之间的天数 - Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找通过Android API并一直在寻找一种方法来计算当前日期和未来日期之间的天数。我对Android很新,我几年没做过java。什么是最容易计算的方法?

I been looking thru the Android API and been looking for a way to calculate the number of days between the current date and a future date. I'm pretty new to android and i havent done java in a few years. Whats the easiest method to calculate this?

谢谢

推荐答案

最简单的方法是使用 Joda Time Days课程:

The easiest way is to use the Joda Time Days class for this:

Date oldEventDate = ...
Date newEventDate = ...
Days days = Days.daysBetween(new DateTime(oldEventDate), new DateTime(newEventDate));
int numberOfDays = p.getDays();

这篇关于计算事件之间的天数 - Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆