i working in application facing issue time zones.
want convert utc millisecond utc date object.
i tried
timezone utczone = timezone.gettimezone("utc"); calendar date = getinstance(utczone); date.settimeinmillis(utcmillisecond); date.gettime();
date.gettime still returning local time zone est. know millisecond getting ui in utc millisecond.
the old class java.util.calendar silently applied jvm’s current default time zone. assumed in utc not.
java.time
you using old troublesome date-time classes have been supplanted java.time framework in java 8 , later.
i assume "utc millisecond" mean count of milliseconds since first moment of 1970 in utc, 1970-01-01t00:00:00z
. can used directly create java.time.instant
, moment on timeline in utc.
by way aware java.time has nanosecond resolution, finer milliseconds.
instant instant = instant.ofepochmilli( yourmillisnumber );
call tostring
generate string textual representation of date-time value in format compliant iso 8601 standard. example:
2016-01-23t12:34:56.789z
Comments
Post a Comment