TL;DR
myPreparedStatetment.setObject(
… ,
LocalDateTime.parse(
"2012-04-13 04:08:42.794".replace( " " , "T" )
)
)
SJuan76 : Date::toString. java.time.
java.time
java.time, , Date/Calendar.
, ISO 8601. SPACE T.
String input = "2012-04-13 04:08:42.794".replace( " " , "T" ) ;
LocalDateTime, --UTC .
LocalDateTime ldt = LocalDateTime.parse( input ) ;
ldt.toString(): 2012-04-13T04: 08: 42.794
SQL
java.sql, . java.time. JDBC 4.2, java.time . , java.sql.Date .
myPreparedStatement.setObject( … , ldt ) ;
...
LocalDateTime ldt = myResultSet.getObject( … , LocalDateTime.class ) ;
# 1: , .
# 2: java.time. .
java.time
java.time Java 8 . legacy , java.util.Date, Calendar SimpleDateFormat.
Joda-Time, , java.time.
, . Oracle. Qaru . JSR 310.
JDBC-, JDBC 4.2 java.time- . java.sql. * Classes.
java.time?
The ThreeTen-Extra project extends java.time with additional classes. This project is a proof of possible future additions to java.time. Here you can find useful classes, such as Interval, YearWeek, YearQuarterand longer .