Spring Mybatis date comparison (1) ------ datetime type

foreword

Everyone may have different data table design ideas, some people like to use timestamp, and some people like to use datetime. Let's talk about the table fields of datetime type and the data types supported when doing size comparison.

text

Type one

java.util.Date type, this type can be directly passed to the field datetime type field in the mapper class for ordinary size comparison.

Date date = new Date();

Type two

java.lang.String type, this type needs to convert the time into a fixed format, and then pass it into the field datetime type field in the mapper class for ordinary size comparison.

Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateStr = format.format(date);

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325958735&siteId=291194637