In [1]:
spark.version
Out[1]:
2.4.8

string to java.sql.Timestamp

just use Timestamp.valueOf

In [5]:
import java.sql.Timestamp

val ts = Timestamp.valueOf("2022-05-12 12:00:00.123")
ts = 2022-05-12 12:00:00.123
Out[5]:
2022-05-12 12:00:00.123

time.Instant to sql.Timestamp

In [8]:
import java.time.Instant
import java.sql.Timestamp

val instantObj = Instant.now()

val ts = Timestamp.from(instantObj)
instantObj = 2022-06-13T04:37:01.378Z
ts = 2022-06-13 01:37:01.378
Out[8]:
2022-06-13 01:37:01.378