String today=null;
Date date=new Date(); //输出date为什么是null呢,
DateFormat format=new SimpleDateFormat("yyyy-MM-dd"); //看API没看懂,DateFormat是个什么类,起的什么作用,为什么要用它, 还有为什么要用new SimpleDateFormat("yyyy-MM-dd"); 初始化呢
today = format.format(date); //还有这个
Date date=new Date(); //输出date为什么是null呢,
DateFormat format=new SimpleDateFormat("yyyy-MM-dd"); //看API没看懂,DateFormat是个什么类,起的什么作用,为什么要用它, 还有为什么要用new SimpleDateFormat("yyyy-MM-dd"); 初始化呢
today = format.format(date); //还有这个
Date date=new Date(); //输出date为什么是null呢,
----------
是当前时间,不会是null的
DateFormat format=new SimpleDateFormat("yyyy-MM-dd"); //看API没看懂,DateFormat是个什么类,起的什么作用,为什么要用它,
------------------
日期格式化的
你可以年月日,也可以日月年,还可以用其他的方式
比如:DateFormat format=new SimpleDateFormat("yyyy年MM月dd不日");
还有为什么要用new SimpleDateFormat("yyyy-MM-dd"); 初始化呢
today = format.format(date); //还有这个
第二问 日期格式化的(为什么要格式化,格与不格的区别是什么呢) new SimpleDateFormat("yyyy-MM-dd"); 里面的参数要怎样定义呢,随便定义吗?
DateFormat format=new SimpleDateFormat("yyyy-MM-dd");
为什么不用
DateFormat format=new DateFormat ()
初始化呢
外部类不能访问
Class DateFormat
java.lang.Object
java.text.Format
java.text.DateFormat
All Implemented Interfaces:
Serializable, Cloneable
Direct Known Subclasses:
SimpleDateFormat