The best way to store time in Java is HH: mm

After doing my research, I can't find the method or data type that should be used for variables to store time in HH: mm format, I did find a way to get this method from a string like "14:15": 10 ", but I don't think it's the best way because I need to add or subtract time. I tried to do this is a double, but I encountered the following problem. When you have a time stored like 05.45 and add 0.15 (or 15 minutes), the result is 05.60, which is in the format of HH: mm. You want it to be 06.00

I've read the Java documentation, but I still do, but I can't seem to find any way to achieve this. My closest is the date format, such as DD / mm / yyyy HH: mm: SS

Solution

Use joda time It provides better date / time operations than standard Java dates If you want to use an internal JDK class, use Java util. Date.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>