79130697

Date: 2024-10-27 13:45:32
Score: 0.5
Natty:
Report link

I know why!!!

The reason why seems obviously.

I misuse the flag to create a java.text.SimpleDateFormat instance (occurred in /HealthHelper/src/main/java/util/gson/deserializer/JsonDeserializerForSqlDate.java) so that the java.sql.Date parsing is wrong.

In this statement

SimpleDateFormat dateFormat = new SimpleDateFormat(SqlDatePattern.sqlDatePattern);

the static field SqlDatePattern.sqlDatePattern is assigned to yyyy-MM-DD.

I change it into yyyy-MM-dd.

I also change SqlTimePattern.sqlTimePattern from hh:mm:ss to HH:mm:ss

in the following statement.

SimpleDateFormat timeFormat = new SimpleDateFormat(SqlTimePattern.sqlTimePattern);

Then I test it again, getting expected result.

In console in Eclipse, it prints

Ready to deserialize.
dietDiary:DietDiary [diaryId=2, userId=2, createDate=2022-05-05, createTime=12:00:00, totalFat=2.52, totalCarbon=2.3, totalProtein=2.1, totalFiber=2.1, totalSugar=1.2, totalSodium=1.1, totalCalories=1.21]
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: 黃奕捷