• Java基础知识回顾-16(Date,DateFormat和Calendar)


    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月。

    日期是有大小关系的,时间靠后,时间越大。

  • 相关阅读:
    pip3 install的时候报错timed out
    小程序经验
    require()  module.export    Object.keys()
    canvas
    弹框时出现灰色背景
    template模板的使用方法
    javascript中array常用属性方法
    封装数据请求
    wx 参数传值
    ELF文件格式分析
  • 原文地址:https://www.cnblogs.com/zhangrui0328/p/9088971.html
Copyright © 2020-2023  润新知