String to ZonedDateTime is changing format
String ip="2011-05-01T06:47:35.422-05:00"; ZonedDateTime mzt = ZonedDateTime.parse(ip).toInstant().atZone(ZoneOffset.UTC); System.out.println(mzt); System.out.println("-----"); String ip2="2011-05-01T00:00:00.000-05:00"; ZonedDateTime mzt2 = ZonedDateTime.parse(ip2).toInstant().atZone(ZoneOffset.UTC); System.out.println(mzt2); Output: 2011-05-01T11:47:35.422Z ----- 2011-05-01T05:00Z Why is the date format getting changed in case 2? I am getting SQLServer Database error due to this. This is what toString from documentation said The format used will be the shortest that outputs the full value of