I believe that the currently accepted answer is incorrect. Although java.sql.Time implies that its date fields are set to 1970-1-1, this is not true. If you use conversion
new java.sql.Time(new LocalTime(...).toDateTimeToday().getMillis())
then the internal millisecond representation of the java.sql.Time object will reflect today's date. This leads to unexpected behavior when comparing java.sql.Time objects. The comparison is performed on a millisecond value, and if the base dates are different, the time fields are not related to the result of the comparison.
The best method is to explicitly work with time fields using the deprecated constructor and methods in java.sql.Time:
LocalTime localTime = new LocalTime(1,0,0,0); java.sql.Time sqlTime = new java.sql.Time(localTime.getHourOfDay(), localTime.getMinuteOfHour(), localTime.getSecondOfMinute())
Similarly in the other direction
java.sql.Time sqlTime = new java.sql.Time(1,0,0); LocalTime localTime = new LocalTime(sqlTime.getHours(), sqlTime.getMinues(), sqlTime.getSeconds());
source share