4

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

Bastian
  • 59
  • 1
  • 6
  • 3
    `EPOCH` was introduced in Java 9, so if you are targeting Java 8 it is not available. – Zircon Aug 21 '19 at 13:29
  • `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. – Meno Hochschild Aug 23 '19 at 06:47
  • @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. – Bastian Aug 23 '19 at 08:03

1 Answers1

6

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)
marstran
  • 19,484
  • 2
  • 45
  • 58
  • [Looks like there is.](https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/time/LocalDate.html#EPOCH) – VGR Aug 21 '19 at 13:30
  • 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! – Bastian Aug 21 '19 at 13:36