问题
I want to cast a ZonedDateTime object into a java.sql.Timestamp object without using the local date.
For example, let's say I have the following datetime :
System.out.println(myZonedDateTime);
> 2018-09-02T23:55:05+04:00[Asia/Dubai]
And my local timezone is UTC+08:00
I try to parse my ZonedDateTime to a Timestamp :
Timestamp t = Timestamp.from(myZonedDateTime.toInstant());
System.out.println(t);
> 2018-09-03 04:55:05.0
The value I get in my timestamp depends of my local time, when I want it to depends of the ZoneId of my data.
How is it possible to do this ?
来源:https://stackoverflow.com/questions/52943309/java-sql-timestamp-to-zoneddatetime