How to get the current time in java time string

How to get the current time by Java
and convert it into format.

		long l = System.currentTimeMillis();
		//new date pair
		Date date = new Date(l);
		//convert to date output format
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String response = dateFormat.format(date).replaceAll("[[\\s-:punct:]]","");

2021-05-07 09:35:47response=202105

Read More: