what is the best way to convert a java.time.Duration-object to java.sql.Time?
I am gettng an ISO8601-String like PT15M51S and Duration.parse(String s) is quite suitable in this case.
But now i am struggeling how to get the java.sql.Time to but it into PreparedStatement with setTime(java.sql.Time time) to store it in my MySQL-database using JDBC.
I ended up writing a tapeworm like from org.apache.commons.lang3.time.DurationFormatUtils:
java.sql.Time.valueOf(DurationFormatUtils.formatDurationHMS(video.getDuration().toMillis())))
And for the next problem: How to get java.time.duration from a java.sql.time
Aucun commentaire:
Enregistrer un commentaire