对于序列化的实现,当是实现Serializable接口时,可以通过关键字transient表示该属性不需要进行实例化。
对于时间类的说明以及介绍
Date ->java.util.Date;
他的构造方法就是两种
Date()
Date(long nmins)这个是通过毫秒数进行时间的设置。
Calendar是一个抽象类,如果进行操作的话用GregorianCalendar类。
他有几个可以通过类名进行调用的常量。
他的几个方法:
public static Calendar getInstance()获得默认时区实例化对象
public boolean after(Object when)
public boolean before(Object when)比较时间的先后。
public int get(int field)对 常量进行时间转换读取
DateFormat类的使用
他的两种特别重要而且常用的方法:
getDateTimeInstance(int style,Locale a)得到相应字符集语言格式的时间以及日期。
getDateInstance(int style,Locale a)得到相应的字符集语言格式的日期。
SimpleDateFormat类
通过格式化模板标记进行格式化操作
(yyyy-MM-dd-HH-mm-ss-SSS)
他的构造方法有(进行格式化,会产生异常,所以要进行抛出异常处理)
:SimpleDateFormat(String pattern)指定格式的模块
SimpleDateFormat(String pattern,Locale locale)特定语言环境的模块。
SimpleDateFormat.parse(String text)通过这个模块将一个符合条件的字符串提取为一个Date类型的对象。
SimpleDateFormat.format(Date x)将Date对象转换成符合本模块的字符串。