Date,DateFormat,Calendar,

String birth="1993-03-06" ; //设置年月日

SimpleDateFormat s=new SimpeDateFormat("yyyy-MM-dd"); //设定格式

Date b=s.parse(birth); //创建日起对象

long btime=b.getTime(); //转为毫秒

long now=new Date().getTime; //获取当前日期并转为毫秒

long days=(now-btime)/1000/60/60/24; //计算将毫秒转为天数。

Calendar:

Calendar c=new Calendar()

创建calenday的对象的毫秒数:

long ctime=c.getTime().getTime();

猜你喜欢

转载自www.cnblogs.com/god3064371/p/11579433.html