Skip to content
Advertisement

What is the Signature of LocalTime datatype in Java to create objects with it ? int/string cannot be applied to LocalTime Error [closed]

This is in my constructor in class Office.

JavaScript

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

JavaScript

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.

Advertisement

Answer

We can more briefly define your class as a record in Java 16+. A record is appropriate if the main purpose of your class is to communicate data transparently and immutably. The compiler implicitly creates the constructor, getters, equals & hashCode, and toString.

JavaScript

Instantiate. Pay attention to 24-hour clock.

JavaScript

You obviously have yet to master the basics of the Java language. Please study your textbook and other resources before posting here. Oracle provides the Java Tutorials free of cost.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement