1、Date得到当天时间
Date dNow = new Date();2、Date得到具体某天
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");String data = sdf.format(dNow); //获取的为当天时间 年-月-日
Date date= new Date(int year, int month, int date)3、通过Calendar获取当天时间
//year 从 1900 开始,month从0开始算比如:Date dNow = new Date(3,2,1); //获取值为1903-03-01

本文介绍了如何使用Date和Calendar类获取当前、指定以及未来日期的方法,并提供了示例代码,如通过sdf.format()方法展示日期格式。同时,还提到了如何计算朋友圈发布时间。
最低0.47元/天 解锁文章
1785

被折叠的 条评论
为什么被折叠?



