Date now = new Date();
System.out.println( "new Date() =" + new Date());// 打印当前系统时间 System.out.println( "new Date().getTime() ="+ new Date().getTime());//打印当前系统时间以毫秒为单位 System.out.println( "new Date((new Date().getTime()+5*60*1000)) ="+ new Date((new Date().getTime()+5*60*1000)));//打印当前系统时间+5分钟以毫秒为单位
String sNow = DateUtils.getDate2YmdhmsString(new Date());
System.out.println( "DateUtils.getDate2YmdhmsString(new Date()) ="+ DateUtils.getDate2YmdhmsString(new Date()));//打印当前系统时间以yyyyMMddHHmmss格式
打印:
new Date() =Mon Mar 04 14:28:26 CST 2019
new Date().getTime() =1551680906227new Date((new Date().getTime()+5*60*1000)) =Mon Mar 04 14:33:26 CST 2019DateUtils.getDate2YmdhmsString(new Date()) =20190304142826