Android date/time displaying 0 instead of 12

前端 未结 2 566
隐瞒了意图╮
隐瞒了意图╮ 2021-01-07 14:43

I wonder what\'s wrong with my code below:

 // Assign hour set in the picker
        c.set( Calendar.HOUR, selectedHour );
        c.set( Calendar.MINUTE, se         


        
相关标签:
2条回答
  • 2021-01-07 15:27

    Use this to check for AM or PM.

    c.get(Calendar.AM_PM);
    

    See here for documentation Calendar.AM_PM

    0 讨论(0)
  • 2021-01-07 15:30
     hour = c.get( Calendar.HOUR );
     minute = c.get( Calendar.MINUTE );
     hour = c.get( Calendar.HOUR_OF_DAY );
    

    You are setting hour again after it was already set.

    0 讨论(0)
提交回复
热议问题