我想知道android开发中是否有类似时间跨度的东西?
在 C# 中有类似的东西,我喜欢以两种方式使用它:
- 生成一个时间跨度,然后添加例如分钟,然后显示整个跨度
- 生成两个 DateTime 之间的时间跨度(Android 中 DateTime 的等效项是什么?)
public long addSeconds(long dt,int sec) //method to add seconds in time
{
Date Dt = new Date(dt);
Calendar cal = new GregorianCalendar();
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss");
sdf.setCalendar(cal);
cal.setTimeInMillis(Dt.getTime());
cal.add(Calendar.SECOND, sec);
return cal.getTime().getTime();
}
以秒为单位传递日期和时间,它将返回修改后的时间...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)