SHARE
TWEET

new Date() Optimization

a guest Jun 12th, 2013 33 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
Want to get better at Java?
Learn to code Java in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top