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