import java.time.LocalDate;
public class Main {
public static void main(String[] args) {
LocalDate ld = new LocalDate.of(2000,10,20);
}
}
I'm using IntelliJ IDEA Community Edition 15.0.3. When I try to use LocalDate.of it shows "Cannot resolve symbol 'of'". I tried typing "o" and then enter but it still doesn't work. When trying to compile and run it says:
"Error:(14, 37) java: cannot find symbol
symbol: class of
location: class java.time.LocalDate"
LocalDate of() method in Java with Examples The of(int, int, int) method of LocalDate class in Java is used to create an instance of LocalDate from the input year, month and day of the month. In this method, all the three parameters are passed in the form of integer.
It should not be null. Return value: This method returns LocalTime which is the parsed local date-time. Exception: This method throws DateTimeParseException if the text cannot be parsed.
LocalDate is an immutable class that represents Date with default format of yyyy-MM-dd.
LocalDateTime is an immutable date-time object that represents a date-time, often viewed as year-month-day-hour-minute-second. Other date and time fields, such as day-of-year, day-of-week and week-of-year, can also be accessed. Time is represented to nanosecond precision.
Because of your new
operator, you are attempting to instantiate a nested class called of
within LocalDate
, which does not exist.
Remove new
so it can parse as the static
method of
within LocalDate
.
LocalDate ld = LocalDate.of(2000,10,20);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With