I am using SimpleDateFormat to change string to date format and serverTimezone in UTC but date is saved 1 day earlier:
String date="2020-05-05";
public static Date getDateByStringDateYYYYMMDD(String date) {
try {
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
return format.parse(date);
} catch (Exception ex) {
throw new GenricException(ex.getMessage());
}
}
url: jdbc:mysql://localhost:3306/testdb?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true
date is save in mysql is like 2020-05-04