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