java.util.Date and the UTC problem -
i know has been hot topic on time... can't find suitable answer.
i have current utc time in ms, need compare current time in machine (so should match).
long myutctime = .....; // reflects utc time // mydate in utc, ok, agree date mydate = new date(); // when use gettime() localtime in ms, although not in utc! in dst long milis = mydate.gettime(); // here 60 minute difference long difference = milis - myutctime;
how can this?
thanks in advance.
edit: don't need calendar or anything. i'm not showing information user, want use utc times, , date supposed in utc
date mydate = new date(); long milis = mydate.gettime();
should equivalent simpler:
long milis = system.currenttimemillis();
both should return
the difference, measured in milliseconds, between current time , midnight, january 1, 1970 utc
quick check in linux box:
# cat x.java public class x { public static void main(string[] args) { system.out.println( (new java.util.date()).gettime()); system.out.println( system.currenttimemillis()); } } # javac x.java ; java x ; perl -e 'print time()*1000' 1305133124654 1305133124654 1305133124000
perhaps have interpretation issue...
Comments
Post a Comment