Comparing two times in android

前端 未结 4 918
梦如初夏
梦如初夏 2021-01-02 23:57

I have tried with the below code to compare two times:

   SimpleDateFormat sdf = new SimpleDateFormat(\"hh:mm\");
    Date inTime = sdf.parse(\"11:00\");
            


        
4条回答
  •  滥情空心
    2021-01-03 00:52

    Change SimpleDateFormat like below...

    SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
    

    Below are the patterns:

    H   Hour in day (0-23)  Number  0
    k   Hour in day (1-24)  Number  24
    K   Hour in am/pm (0-11)    Number  0
    h   Hour in am/pm (1-12)    Number  12
    

    This will work....

提交回复
热议问题