org.apache.commons.net.ftp.parser
Class FTPTimestampParserImpl
java.lang.Object
org.apache.commons.net.ftp.parser.FTPTimestampParserImpl
- Configurable, FTPTimestampParser
public class FTPTimestampParserImpl
extends java.lang.Object
implements FTPTimestampParser, Configurable
Default implementation of the FTPTimestampParser
interface also implements the Configurable
interface to allow the parsing to be configured from the outside.
ConfigurableFTPFileEntryParserImpl
FTPTimestampParserImpl
public FTPTimestampParserImpl()
The only constructor for this class.
configure
public void configure(FTPClientConfig config)
Implementation of the
Configurable
interface. Configures this
FTPTimestampParser
according
to the following logic:
Set up the
defaultDateFormat
and optionally the
recentDateFormat
to values supplied in the config based on month names configured as follows:
- If a
shortMonthString
has been supplied in the config
, use that to parse parse timestamps. - Otherwise, if a
serverLanguageCode
has been supplied in the config
, use the month names represented
by that language
to parse timestamps. - otherwise use default English month names
Finally if a
serverTimeZoneId
has been supplied via the config, set that into all date formats that have
been configured.
getDefaultDateFormat
public SimpleDateFormat getDefaultDateFormat()
- Returns the defaultDateFormat.
getDefaultDateFormatString
public String getDefaultDateFormatString()
- Returns the defaultDateFormat pattern string.
getRecentDateFormat
public SimpleDateFormat getRecentDateFormat()
- Returns the recentDateFormat.
getRecentDateFormatString
public String getRecentDateFormatString()
- Returns the recentDateFormat.
getServerTimeZone
public TimeZone getServerTimeZone()
- Returns the serverTimeZone used by this parser.
getShortMonths
public String[] getShortMonths()
- returns an array of 12 strings representing the short
month names used by this parse.
parseTimestamp
public Calendar parseTimestamp(String timestampStr)
throws ParseException
Implements the one method
in the 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.
This method allows a Calendar
instance to be passed in which represents the
current (system) time.
timestampStr
- The timestamp to be parsed
org.apache.commons.net.ftp.parser.FTPTimestampParser.parseTimestamp(java.lang.String)
parseTimestamp
public Calendar parseTimestamp(String timestampStr,
Calendar serverTime)
throws ParseException
Implements the one method
in the 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.
timestampStr
- The timestamp to be parsedserverTime
- The current time for the server
org.apache.commons.net.ftp.parser.FTPTimestampParser.parseTimestamp(java.lang.String)