Discrepancy when converting ancient dates between java.util.Date and java.time.Instant
up vote
4
down vote
favorite
I have legacy code that uses java.util.Date creating an ancient date (30 Nov 0002). I'm trying to update what code I can, but that's necessitating converting between Date and LocalDate, etc. I can't completely get rid of the use of Date or the ancient date choice. I'm finding what appears to be an error when converting back and forth between Date and Instant with this ancient date, and was hoping someone could explain what is going on. Here's a sample: Date date = new Date(); Instant instant = date.toInstant(); System.out.println("Current:"); System.out.println("Date: "+date); System.out.println("Instant: "+instant); System.out.println("Date epoch: "+date.getTime()); System.out.println("Instant epo...