This is in my constructor in class Office.
public Office(String name, String location, LocalTime openingTime, LocalTime closingTime) {
this.name = name;
this.location = location;
this.openingTime = openingTime;
this.closingTime = closingTime;
}
Now, I want to create an object of Class Office with LocalTime being one of the attributes. However I'm unable to pass the values for Localtime while creating the object. I'm trying
Office office1=new Office("Company Name","Chennai",10:30,6:30);
//Or this
Office office1=new Office("Company Name","Chennai",10,6);
//Or this
Office office1=new Office("Company Name","Chennai",'10:30','6:30');
//Or this
Office office1=new Office("Company Name","Chennai","10:30","6:30");
None of these is working so far. It is not matching with the signature of the data type LocalTime. Would appreciate the solution to this.
LocalTimefor the arguments. See the documentation for available static factory methods (e.g., theof(...)methods, or theparse(...)methods, though the former seems more appropriate for your use case). As an example,LocalTime.of(10, 30)would give you aLocalTimeinstance for 10:30 AM.