1

I want to convert UTC time to my desiered time zone, Im trying with the following code

        //inputDate - Timestamp (2016-10-15 12:30:00)
        //toZoneId -  Australia/Sydney

        ZonedDateTime utcDateTime = ZonedDateTime.ofInstant(inputDate.toInstant(), ZoneId.of("UTC"));
        Timestamp convertedTime = Timestamp.valueOf(utcDateTime.withZoneSameInstant(ZoneId.of(toZoneId)).toLocalDateTime());
        return convertedTime;

I get same "2016-10-15 12:30:00" as output not the UTC equivalent date time. What am I missing?

syv
  • 3,528
  • 7
  • 35
  • 50
  • Possible duplicate of [Convert Date/Time for given Timezone - java](http://stackoverflow.com/questions/7670355/convert-date-time-for-given-timezone-java) – Dez Oct 06 '16 at 15:28
  • What is the value of `inputDate.toLocalDateTime()`? – VGR Oct 06 '16 at 19:25

0 Answers0