时间格式化SimpleDateFormat和FastDateFormat
SimpleDateFormat和FastDateFormat主要都是对时间的格式化
FastDateFormat是线程安全的,可以直接使用,不必考虑多线程的情况
SimpleDateFormat在对时间进行格式化的方法format中,会先对calendar对象进行setTime的赋值,若是有多个线程同时操作一个SimpleDateFormat实例的话,就会对calendar的赋值进行覆盖,进而产生问题。
FastDateFormat format = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss"); System.out.println(format.format(new Date()));