I am using a SQL Server which has a column with dateTime. I want to insert the user input String into the DB, for which i try to insert using timestamp.
Following code in Java converts String to ZonedDateTime.
Case 1:
String ip="2018-05-01T06:47:35.422-05:00";
ZonedDateTime zdt = ZonedDateTime.parse(ip, DateTimeFormatter.ISO_ZONED_DATE_TIME);
System.out.println(Timestamp.from(zdt.toInstant()));
Output is 2018-05-01 06:47:35.422
Case 2:
If String ip="2011-04-07T00:00:00.000-04:00"; Output is 2011-04-06 23:00:00.0
In the second case, why is the date getting changed to previous day and the time is considering offset?