SHARE
TWEET

new Date() Optimization

a guest Jun 12th, 2013 29 Never
  1.     private Date now;
  2.     private long nowLastUpdate;
  3.    
  4.     private Date getNow() {
  5.         long nowMillis = System.currentTimeMillis();
  6.         if (now == null || nowMillis - nowLastUpdate >= 60 * 1000) {
  7.                 now = new Date();
  8.                 nowLastUpdate = nowMillis;
  9.         }
  10.         return now;
  11.     }
RAW Paste Data
Top