How to get the current time in java time string

How to get the current time by Java
and convert it into java.sql.date 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");
		System.out.println(dateFormat.format(date)); 
		
		String response = dateFormat.format(date).replaceAll("[[\\s-:punct:]]","");
		System.out.println("response="+response);

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

Read More: