java sql date format code example
Example: java sql date format
// This is an example to get the current date in java, with an sql date format
/*
I am using the imports below:
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
*/
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime now = LocalDateTime.now();
String dateTime = dtf.format(now);
// the dateTime variable is now ready to be inserted in mysql
// insert it as a String and it will be inserted in mysql as a dateTime