JodaTime uses computer time internally. Thus, to find miliseconds, you can use LocalDateTime persistent storage with reference to January 1, 1970 (Due to UNIX Time ).
Unix time or POSIX time is a system for describing points in time, defined as the number of seconds elapsed from the midnight prolits Coordinated universal time (UTC) from January 1, 1970, not counting the leap seconds. Then calculate the difference between your DateTime.
I tried like this:
public static void main(String[] args) { final LocalDateTime JAN_1_1970 = new LocalDateTime(1970, 1, 1, 0, 0); DateTime local = new DateTime().withZone(DateTimeZone.forID("Europe/Amsterdam")); DateTime utc = new DateTime(DateTimeZone.UTC); System.out.println("Europe/Amsterdam milis :" + new Duration(JAN_1_1970.toDateTime(DateTimeZone.forID("Europe/Amsterdam")), local).getMillis()); System.out.println("UTC milis :" + new Duration(JAN_1_1970.toDateTime(DateTimeZone.UTC), utc).getMillis()); }
And the result:
Europe/Amsterdam milis :1429695646528 UTC milis :1429692046534
And @leonbloy write a good comment here .
Your local and utc represent the same time points (only from different timelines). Therefore, getMillis () (which gives the βphysicalβ time interval elapsed from the βmomentβ corresponding to the unix epoch) should return the same value.
Semih eker
source share