1、 System.currentTimeMillis() 返回值long类型参数 ,用于获取当前日期的毫秒值。
2、Date date = new Date();获取当前时间的date格式,在括号里填入毫秒数,可以转换为date。
3、Date的.getTime()方法,将date格式转为毫秒类型。
4、SimpleDateFormat df= new SimpleDateFormat("yyyy-MM-dd")//设置“yyyy-MM-dd”格式化对象
Date date = new Date();//获取当前时间
String str_time = df.format(date);把date以df格式转化为字符串,传给str_time。
5、Calendar c=Calendar.getInstance()//获取当前时间的calendar格式。
6、Calendar的常用方法
7、注意事项:
西方星期的开始为周日,中国为周一。
在Calendar类中,月份的表示是以0-11代表1-12月。
日期是有大小关系的,时间靠后,时间越大。