The java.sql.Timestamp
extends java.util.Date
, so you can format it exactly the same way:
String formattedDate = new SimpleDateFormat("yyyyMMdd").format(date);
Parsing is almost the same, you can construct it using its “millis” representation:
Timestamp timestamp = new Timestamp(new SimpleDateFormat("yyyyMMdd").parse(formattedDate).getTime());