LocalDate.EPOCH is not available
Asked Answered
C

1

6

I need to normalise some Data to execute a SQL-Statement. Unfortunately I can't initialize a LocalDate-variable with LocalDate.EPOCH. MIN and MAX are working.

startDatum = startDatum == null? LocalDate.EPOCH : startDatum; // doesn't work
endDatum = (endDatum == null)? LocalDate.MAX : endDatum; // works

Eclipse only says EPOCH cannot be resolved or is not a field

Citrine answered 21/8, 2019 at 13:26 Comment(3)
EPOCH was introduced in Java 9, so if you are targeting Java 8 it is not available.Karakalpak
LocalDate.EPOCH is just a (confusing) symbol for the arbitrary date 1970-01-01. Why do you want to choose this date as start in case of missing content? I don't understand your use-case.Blasien
@MenoHochschild the query returns bills starting at about 1990. I won't need exactly the begin of unixtime, but i found this as a good predefined date to get all bills returned.Citrine
M
9

The EPOCH field on LocalDate was new in Java 9. If you're using Java 8, you can do the following to get the LocalDate at epoch:

LocalDate.ofEpochDay(0)
My answered 21/8, 2019 at 13:29 Comment(2)
Looks like there is.Quillen
Oh wow... thats a bit embarrassing. Our project is at Java 8. My problem was that I'm using jdk-11 as source view in Eclipse and even looking in the Java 11 API because of the livesearch field. Thank you!Citrine

© 2022 - 2025 — McMap. All rights reserved.