Unexpected difference in dates parsed using yyyy-MM-dd hh:mm:ss format

后端 未结 2 2001
太阳男子
太阳男子 2021-01-18 01:09

I\'ve run the below java code to get time difference.

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.         


        
2条回答
  •  猫巷女王i
    2021-01-18 01:42

    Changing the SimpleDateFormat pattern to yyyy-MM-dd HH:mm:ss fixes the issues.

    This happens because in the yyyy-MM-dd hh:mm:ss case, 12 is evaluated as 0.

提交回复
热议问题