1 package org.djutils.decoderdumper;
2
3 import java.io.IOException;
4
5
6
7
8
9
10
11
12
13
14
15
16 public class TimeStamper implements Decoder
17 {
18
19 private String result = "";
20
21
22 @Override
23 public String getResult()
24 {
25 String retVal = this.result;
26 this.result = "";
27 return retVal;
28 }
29
30
31 @Override
32 public int getMaximumWidth()
33 {
34 return 14;
35 }
36
37
38 @Override
39 public boolean append(int address, byte theByte) throws IOException
40 {
41 if (this.result.length() == 0)
42 {
43 long now = System.currentTimeMillis();
44 this.result = String.format("%10d.%03d ", now / 1000, now % 1000);
45 }
46 return false;
47 }
48
49
50 @Override
51 public boolean ignoreForIdenticalOutputCheck()
52 {
53 return false;
54 }
55
56
57 @Override
58 public String toString()
59 {
60 return "TimeStamper [result=" + this.result + "]";
61 }
62
63 }