File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
core/src/main/java/cucumber/runtime/xstream Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 15
15
16
16
abstract class TimeConverter <T > extends ConverterWithFormat <T > {
17
17
private final List <DateFormat > formats = new ArrayList <DateFormat >();
18
- private SimpleDateFormat onlyFormat ;
18
+ private String format ;
19
19
20
20
TimeConverter (Locale locale , Class [] convertibleTypes ) {
21
21
super (convertibleTypes );
@@ -37,7 +37,14 @@ void add(DateFormat dateFormat) {
37
37
}
38
38
39
39
public List <? extends Format > getFormats () {
40
- return onlyFormat == null ? formats : asList (onlyFormat );
40
+ return format == null ? formats : asList (getOnlyFormat ());
41
+ }
42
+
43
+ private Format getOnlyFormat () {
44
+ DateFormat dateFormat = new SimpleDateFormat (format , getLocale ());
45
+ dateFormat .setLenient (false );
46
+
47
+ return dateFormat ;
41
48
}
42
49
43
50
@ Override
@@ -51,14 +58,14 @@ public String toString(Object obj) {
51
58
@ Override
52
59
public void setParameterInfoAndLocale (ParameterInfo parameterInfo , Locale locale ) {
53
60
super .setParameterInfoAndLocale (parameterInfo , locale );
61
+
54
62
if (parameterInfo .getFormat () != null ) {
55
- onlyFormat = new SimpleDateFormat (parameterInfo .getFormat (), locale );
56
- onlyFormat .setLenient (false );
63
+ format = parameterInfo .getFormat ();
57
64
}
58
65
}
59
66
60
67
public void removeOnlyFormat () {
61
- onlyFormat = null ;
68
+ format = null ;
62
69
}
63
70
64
71
public static List <Class > getTimeClasses () {
You can’t perform that action at this time.
0 commit comments