Message-ID: From: "marschall (@marschall)" To: "pgjdbc/pgjdbc" Date: Fri, 16 Nov 2018 21:56:17 +0000 Subject: Re: [pgjdbc/pgjdbc] issue #1325: Additional jsr 310 support In-Reply-To: References: List-Id: X-GitHub-Author-Login: marschall X-GitHub-Comment-Id: 439541510 X-GitHub-Comment-Type: issue_comment X-GitHub-Issue: 1325 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-Type: comment X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/1325#issuecomment-439541510 Content-Type: text/plain; charset=utf-8 > I am not sure I agree. What I see is that LocalDateTime -> Timestamp conversion depends on the JVM default time zone. It's the same with String -> Timestamp conversion which like LocalDateTime calls the deprecated constructor, see code below. To get from a date time / SQL TIMESTAMP to an instant / point in time / unix timestamp you need to have a time zone. For java.sql.Timestamp this is the JVM default time zone. ```java String localDateTime = "2018-11-16 18:02:00"; TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); Instant instant1 = Timestamp.valueOf(localDateTime).toInstant(); long epochMilli1 = instant1.toEpochMilli(); TimeZone.setDefault(TimeZone.getTimeZone("America/New_York")); Instant instant2 = Timestamp.valueOf(localDateTime).toInstant(); long epochMilli2 = instant2.toEpochMilli(); System.out.printf("epochMilli1: %d%n", epochMilli1); System.out.printf("epochMilli2: %d%n", epochMilli2); System.out.println("same instant: " + instant1.equals(instant2)); ```