Java how to calculate time differences

前端 未结 2 543
悲&欢浪女
悲&欢浪女 2021-01-23 03:42

How can I calculate the time differences in 24 hour if the user input is 2255 and 2305 the output should be 10 minutes. I got an idea is to separate the input to 2 parts, 2 digi

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-23 04:18

    How to get first 2 digit without using String chartAt.

    Highest two digits: number / 100 Lowest two digist: number % 100

    But what would you do if user enter 3:05 or 3-05? I think it's problem of usability. Best solution is making UI definitely understandable for user. For example you can use separate fields for hours and minutes.

提交回复
热议问题