Date
Date d = new Date();
打印d是当前时间。
d.getTime()是1970.1.1距离现在的毫秒数
calendar日历
打印年份:
Calendar c = Calendar.getInstance(Local.国家名);//Local.国家名可不写,默认是本地
System.out.println(c.get(c.YEAR));
SimpleDateFormat时间格式类
SimpleDateFormat(String pattern)创建默认的本地日期格式符号。注意:此构造函数可能不支持所有区域设置。 要全面覆盖,请使用DateFormat类中的工厂方法。
format(Date date)将Date转化为String;
parse(String string)将String类型的时间转化为Date对象
NumberFormat 数字格式类
nf = NumberFormat.get类型名Instance(Locale.地域名);不加类型名和地域名就是默认本地的。
format(double a)把数字转换成希望的String 类型的格式
parse(String s)把String类型的格式,转换成数字类型
DecimalFormat
是格式为十进制数的NumberFormat的具体子类。
DecimalFormat df = new DecimalFormat("###,###,###.00");```