1 11 13 package com.sun.jmx.snmp; 14 15 16 17 27 28 public class SnmpTimeticks extends SnmpUnsignedInt { 29 30 38 public SnmpTimeticks(int v) throws IllegalArgumentException { 39 super(v) ; 40 } 41 42 48 public SnmpTimeticks(Integer v) throws IllegalArgumentException { 49 super(v) ; 50 } 51 52 61 public SnmpTimeticks(long v) throws IllegalArgumentException { 62 super(((v>0)?v&SnmpUnsignedInt.MAX_VALUE:v)) ; 63 } 64 65 74 public SnmpTimeticks(Long v) throws IllegalArgumentException { 75 this(v.longValue()) ; 76 } 77 78 86 final static public String printTimeTicks(long timeticks) { 87 int seconds, minutes, hours, days; 88 StringBuffer buf = new StringBuffer () ; 89 90 timeticks /= 100; 91 days = (int)(timeticks / (60 * 60 * 24)); 92 timeticks %= (60 * 60 * 24); 93 94 hours = (int)(timeticks / (60 * 60)) ; 95 timeticks %= (60 * 60); 96 97 minutes = (int)(timeticks / 60) ; 98 seconds = (int)(timeticks % 60) ; 99 100 if (days == 0) { 101 buf.append(hours + ":" + minutes + ":" + seconds) ; 102 return buf.toString() ; 103 } 104 if (days == 1) { 105 buf.append("1 day ") ; 106 } else { 107 buf.append(days + " days ") ; 108 } 109 buf.append(hours + ":" + minutes + ":" + seconds) ; 110 return buf.toString() ; 111 } 112 113 119 final public String toString() { 120 return printTimeTicks((long)value) ; 121 } 122 123 127 final public String getTypeName() { 128 return name; 129 } 130 131 136 final static String name = "TimeTicks" ; 137 static final private long serialVersionUID = -5486435222360030630L; 138 } 139 | Popular Tags |