GWT time/string formatting
How can I easily do the following in GWT? (The code below is illegal since String.format
is not emulated.)
long lTime = System.currentTimeMillis() % (24*60*60*1000);
lo开发者_Go百科ng lHour = lTime/(60*60*1000);
long lMin = lTime/(60*1000)%60;
long lSec = lTime/1000%60;
long lMilli = lTime%1000;
return String.format("%d.%.2d:%.2d.%.4d", lHour, lMin, lSec, lMilli);
You should use Date
(yes, most of its methods are deprecated, but that's what the GWT team chose) and DateTimeFormat
精彩评论