DateTimeUtils { public static String timeAsString(Date date) { return FastDateFormat.getInstance(format).format(date); }  static String currentTimeAsString(); static String timeAsString(Date date); static String timeAsString(long timeMilli); synchronized static Date getHoursLaterDate(int hours); synchronized static Date getMinutesLaterThan(Date date, int minute); synchronized static Date getSecondsLaterThan(Date date, int second); static Date getHoursBeforeDate(Date date, int hours); static Date getNearestHour(); static String format; }
@Test public void testFormat() { logger.info(DateTimeUtils.timeAsString(0)); logger.info(DateTimeUtils.timeAsString(1)); logger.info(DateTimeUtils.timeAsString(-1)); }
@Test public void test() { long begin = System.currentTimeMillis(); long time = begin; int count = 1 << 20; String result = null; for (int i = 0; i < count; i++) { result = DateTimeUtils.timeAsString(time++); } long end = System.currentTimeMillis(); logger.info("{} ns", (end - begin) * 1000000 / count); }