我一直在尝试编写一个程序,该程序必须查看csv文件中的某个时间是在某个值之后还是之前。但是,我得到以下错误:
javaFiles\testing.java:116: error: cannot find symbol
boolean before = result.format(formatter).before(calc);
^
symbol: method before(LocalTime)
location: class String
javaFiles\testing.java:117: error: cannot find symbol
boolean after = result.format(formatter).after(calc2);
^
symbol: method after(LocalTime)
location: class String这是给出问题的代码:
LocalTime calc = LocalTime.parse("06:00", formatter);
LocalTime calc2 = LocalTime.parse("17:30", formatter);
//before and after , if true its night
boolean before = result.format(formatter).before(calc);
boolean after = result.format(formatter).after(calc2);有关完整代码,请参阅https://pastebin.com/5EGurJig,这样我就不必在这里发送垃圾邮件了。
发布于 2018-05-18 15:55:25
我不知道变量result有哪个类,但是您正在字符串上调用before和after,因为format调用的结果是一个字符串。因此,如果result也是LocalDate,则只需使用:
boolean before = result.isBefore(calc);
boolean after = result.isAfter(calc2);https://stackoverflow.com/questions/50415076
复制相似问题