Format java.sql.Timestamp into a String

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());

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)