26
26
import java .util .TimeZone ;
27
27
28
28
import org .apache .commons .net .ftp .Configurable ;
29
+ import org .apache .commons .net .ftp .FTPClient ;
29
30
import org .apache .commons .net .ftp .FTPClientConfig ;
30
31
31
32
/**
@@ -44,6 +45,7 @@ public class FTPTimestampParserImpl implements
44
45
private SimpleDateFormat defaultDateFormat ;
45
46
private SimpleDateFormat recentDateFormat ;
46
47
private boolean lenientFutureDates = false ;
48
+ private boolean dateRollbackPermitted = true ;
47
49
48
50
49
51
/**
@@ -91,7 +93,7 @@ public Calendar parseTimestamp(String timestampStr) throws ParseException {
91
93
// slightly in the future to roll back a full year. (Bug 35181)
92
94
now .add (Calendar .DATE , 1 );
93
95
}
94
- if (working .after (now )) {
96
+ if (working .after (now ) && isDateRollbackPermitted () ) {
95
97
working .add (Calendar .YEAR , -1 );
96
98
}
97
99
} else {
@@ -244,6 +246,8 @@ public void configure(FTPClientConfig config) {
244
246
setServerTimeZone (config .getServerTimeZoneId ());
245
247
246
248
this .lenientFutureDates = config .isLenientFutureDates ();
249
+
250
+ this .dateRollbackPermitted = config .isDateRollbackPermitted ();
247
251
}
248
252
/**
249
253
* @return Returns the lenientFutureDates.
@@ -257,4 +261,19 @@ boolean isLenientFutureDates() {
257
261
void setLenientFutureDates (boolean lenientFutureDates ) {
258
262
this .lenientFutureDates = lenientFutureDates ;
259
263
}
264
+
265
+ /**
266
+ * @returns the {@link #dateRollbackPermitted} property
267
+ */
268
+ boolean isDateRollbackPermitted () {
269
+ return dateRollbackPermitted ;
270
+ }
271
+
272
+ /**
273
+ * @see FTPClient#setDateRollbackPermitted(boolean)
274
+ * @param dateRollbackPermitted
275
+ */
276
+ void setDateRollbackPermitted (boolean dateRollbackPermitted ) {
277
+ this .dateRollbackPermitted = dateRollbackPermitted ;
278
+ }
260
279
}
0 commit comments