To print the current time in given format we have to import StandardDateFormat class from java.text library.
import java.text.SimpleDateFormat;
Then we have to create the object of this class.
SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");