Date currentTime = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss"); String date = formatter.format(currentTime); System.out.println(date);