SimpleDateFormat sdf = new SimpleDateFormat("ddMMyyyy_HHmmss", Locale.getDefault()); String currentDateandTime = sdf.format(new Date()); System.out.println("currentDateandTime" + currentDateandTime);