public static void yy() {
Date now = new Date(); // DateFormat dfHour = new SimpleDateFormat("HH:mm"); // dfHour.setTimeZone(TimeZone.getTimeZone("GMT+8:00")); // String nowHour = dfHour.format(now); Calendar cal = Calendar.getInstance(); cal.setTime(now); int hour = cal.get(Calendar.HOUR_OF_DAY); int minute = cal.get(Calendar.MINUTE); String nowHour = (hour < 10 ? "0" : "") + hour + ":" + (minute < 10 ? "0" : "") + minute; }
DateFormat +获取时区:380毫秒 DateFormat +不获取时区,100毫秒 用Calendar:50毫秒 高并发下,还是差别很大的,呵呵
|