org.apache.commons.net.ftp.parser

Class FTPTimestampParserImpl

public class FTPTimestampParserImpl extends Object implements FTPTimestampParser, Configurable

Default implementation of the {@link FTPTimestampParser FTPTimestampParser} interface also implements the {@link org.apache.commons.net.ftp.Configurable Configurable} interface to allow the parsing to be configured from the outside.

Since: 1.4

See Also: ConfigurableFTPFileEntryParserImpl

Constructor Summary
FTPTimestampParserImpl()
The only constructor for this class.
Method Summary
voidconfigure(FTPClientConfig config)
Implementation of the {@link Configurable Configurable} interface.
SimpleDateFormatgetDefaultDateFormat()
StringgetDefaultDateFormatString()
SimpleDateFormatgetRecentDateFormat()
StringgetRecentDateFormatString()
TimeZonegetServerTimeZone()
String[]getShortMonths()
CalendarparseTimestamp(String timestampStr)
Implements the one {@link FTPTimestampParser#parseTimestamp(String) method} in the {@link FTPTimestampParser FTPTimestampParser} interface according to this algorithm: If the recentDateFormat member has been defined, try to parse the supplied string with that.

Constructor Detail

FTPTimestampParserImpl

public FTPTimestampParserImpl()
The only constructor for this class.

Method Detail

configure

public void configure(FTPClientConfig config)
Implementation of the {@link Configurable Configurable} interface. Configures this FTPTimestampParser according to the following logic:

Set up the {@link FTPClientConfig#setDefaultDateFormatStr(java.lang.String) defaultDateFormat} and optionally the {@link FTPClientConfig#setRecentDateFormatStr(String) recentDateFormat} to values supplied in the config based on month names configured as follows:

Finally if a {@link org.apache.commons.net.ftp.FTPClientConfig#setServerTimeZoneId(String) serverTimeZoneId} has been supplied via the config, set that into all date formats that have been configured.

getDefaultDateFormat

public SimpleDateFormat getDefaultDateFormat()

Returns: Returns the defaultDateFormat.

getDefaultDateFormatString

public String getDefaultDateFormatString()

Returns: Returns the defaultDateFormat pattern string.

getRecentDateFormat

public SimpleDateFormat getRecentDateFormat()

Returns: Returns the recentDateFormat.

getRecentDateFormatString

public String getRecentDateFormatString()

Returns: Returns the recentDateFormat.

getServerTimeZone

public TimeZone getServerTimeZone()

Returns: Returns the serverTimeZone used by this parser.

getShortMonths

public String[] getShortMonths()

Returns: returns an array of 12 strings representing the short month names used by this parse.

parseTimestamp

public Calendar parseTimestamp(String timestampStr)
Implements the one {@link FTPTimestampParser#parseTimestamp(String) method} in the {@link FTPTimestampParser FTPTimestampParser} interface according to this algorithm: If the recentDateFormat member has been defined, try to parse the supplied string with that. If that parse fails, or if the recentDateFormat member has not been defined, attempt to parse with the defaultDateFormat member. If that fails, throw a ParseException.

See Also: FTPTimestampParser