blob: 0932f3eeccd24a98314755fc10a9510d929d5629 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
package org.spongycastle.tsp;
import org.spongycastle.asn1.DERInteger;
import org.spongycastle.asn1.tsp.Accuracy;
public class GenTimeAccuracy
{
private Accuracy accuracy;
public GenTimeAccuracy(Accuracy accuracy)
{
this.accuracy = accuracy;
}
public int getSeconds()
{
return getTimeComponent(accuracy.getSeconds());
}
public int getMillis()
{
return getTimeComponent(accuracy.getMillis());
}
public int getMicros()
{
return getTimeComponent(accuracy.getMicros());
}
private int getTimeComponent(
DERInteger time)
{
if (time != null)
{
return time.getValue().intValue();
}
return 0;
}
public String toString()
{ // digits
return getSeconds() + "." + format(getMillis()) + format(getMicros());
}
private String format(int v)
{
if (v < 10)
{
return "00" + v;
}
if (v < 100)
{
return "0" + v;
}
return Integer.toString(v);
}
}
|