1 package org.sapia.ubik.rmi.examples.time; 2 3 import java.text.SimpleDateFormat ; 4 5 import java.util.Date ; 6 7 8 11 public class TimeServiceImpl implements TimeServiceIF { 12 private SimpleDateFormat _theFormat; 13 private int _theCoutner; 14 private String _theId; 15 16 19 public TimeServiceImpl() { 20 System.out.println("Creating a new sticky time service..."); 21 _theFormat = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss z"); 22 _theId = Integer.toHexString(String.valueOf( 23 System.currentTimeMillis()).hashCode()); 24 } 25 26 31 public String getTime() { 32 long aCurrentTime = System.currentTimeMillis(); 33 Date aCurrentDate = new Date (aCurrentTime); 34 String aResult = _theFormat.format(aCurrentDate); 35 36 System.out.println((++_theCoutner) + " - Invocation took " + 37 (System.currentTimeMillis() - aCurrentTime) + " ms @" + _theId); 38 39 return aResult + " @" + _theId; 40 } 41 } 42 | Popular Tags |