首先原谅我的英语:-(
我在java上有几个小时的问题.让我们通过一个例子看到它:
DateFormat datos = new SimpleDateFormat ("hh:mm:ss");
Date ac, lim;
String actual,limit;
actual="18:01:23";
limit="00:16:23";
ac=datos.parse(actual);
lim=datos.parse(limit);
if(ac.compareTo(lim)==-1){.......
Run Code Online (Sandbox Code Playgroud)
我需要解决这种情况,其中限制已经过了午夜,而实际小时则是午夜之前.我的程序说实际已经达到极限并且它不正确,因为在这个例子中,它还有6个小时才能完成.
我试图用DateFormat类解决它,但它没有看到这种情况.我也尝试使用Time类,但不推荐使用它的方法.
我怎么解决这个问题?