1 11 13 package com.sun.jmx.snmp; 14 15 import java.util.Date ; 18 19 26 27 public class Timestamp implements java.io.Serializable { 28 29 30 33 37 private long sysUpTime ; 38 39 42 private long crtime ; 43 44 47 private Date dateCache = null ; 48 49 52 private SnmpTimeticks uptimeCache = null ; 53 54 55 58 62 public Timestamp() { 63 crtime = System.currentTimeMillis() ; 64 } 65 66 72 public Timestamp(long uptime, long when) { 73 sysUpTime = uptime ; 74 crtime = when ; 75 } 76 77 82 public Timestamp(long uptime) { 83 sysUpTime = uptime ; 84 crtime = System.currentTimeMillis() ; 85 } 86 87 88 91 95 final public synchronized SnmpTimeticks getTimeTicks() { 96 if (uptimeCache == null) 97 uptimeCache = new SnmpTimeticks((int)sysUpTime) ; 98 return uptimeCache ; 99 } 100 101 106 final public long getSysUpTime() { 107 return sysUpTime ; 108 } 109 110 114 final public synchronized Date getDate() { 115 if (dateCache == null) 116 dateCache = new Date (crtime) ; 117 return dateCache ; 118 } 119 120 124 final public long getDateTime() { 125 return crtime ; 126 } 127 128 132 final public String toString() { 133 StringBuffer buf = new StringBuffer () ; 134 buf.append("{SysUpTime = " + SnmpTimeticks.printTimeTicks(sysUpTime)) ; 135 buf.append("} {Timestamp = " + getDate().toString() + "}") ; 136 return buf.toString() ; 137 } 138 } 139 | Popular Tags |