simpledateformat java中calendar的用法
一、simpledateformat最小年月
以1970年1月1号为起点0
二、SimpleDateFormat如何定义到毫秒
SimpleDateFormatsdf=newSimpleDateFormat("yyyyMMddhhmmss");SimpleDateFormatsdf=newSimpleDateFormat("yyyyMMddhhmmssSSS")//SSS就是毫秒
三、Datetime如何格式化日期
使用旧的Date对象时,我们用SimpleDateFormat进行格式化显示。使用新的LocalDateTime或ZonedLocalDateTime时,我们要进行格式化显示,就要使用DateTimeFormatter。
和SimpleDateFormat不同的是,DateTimeFormatter不但是不变对象,它还是线程安全的。因为SimpleDateFormat不是线程安全的,使用的时候,只能在方法内部创建新的局部变量。而DateTimeFormatter可以只创建一个实例,到处引用。