#getting current time to in certain format for sql table
1 messages · Page 1 of 1 (latest)
<@&987246584574140416> please have a look, thanks.
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
@hard ridge your JDBC driver can handle that conversion for you
var now = LocalDateTime.now();
var sqlTimestamp = Timestamp.valueOf(now);
var nowAgain = sqlTimestamp.toLocalDateTime();
just convert your LocalDateTime to a sql timestamp
Ohh perfect. Thank you! And I can get rid of the semi colons directly in sql?
LocalDateTime now = LocalDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");
String formattedDateTime = now.format(formatter);
When I do that I get an illegalargumentexception that timestamp must be in format if yyyy-mm-dd hh:mm:ss
don't do what he says. let the jdbc driver ahndle it
but also what do you mean the semicolons?
Trying to get current date and time in format yyyymmddhgmmsss
Sorry I meant colons and dashes 🤦♀️