我一直在尝试编写一个程序,它必须查看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,因此我不必在此处发送垃圾邮件
答案 0 :(得分:2)
我不知道变量result
有哪个类但你在String上调用before
和after
,因为format
调用的结果是一个字符串。因此,如果result
也是LocalDate
,您可以使用:
boolean before = result.isBefore(calc);
boolean after = result.isAfter(calc2);