Commons-net-3.2: mismatch between timestamp and timezone

I am using FTPClient.java, FTPFile.java, FTPListParseEngine.java from commons-net-3.2.jar to access files on an ftp server (Linux machine) located in EET timezone. When accessing files, if I try to see the timezone and timestamp of a file, the timestamp is displayed in UTC, but the timezone is displayed as the timezone of the location where the file is being accessed.

Both were expected to be in EET format.

Example: Suppose the file sample.txt on the FTP server (in the EET zone) is created at 11/27/2014 8:28:20. When accessing the file (in EET timezone) using the jar mentioned above, the FTPFile.java getTimestamp method returns the time as 11/27/2014 6:28:20 AM EET.

Instead, it should have been 11/27/2014 8:28:20 AM EET.

How to solve this problem.

+3


source to share


2 answers


Used FTPClientConfig

to set the timezone to "UTC" and the configured instance FTPClient

with that. The problem has now been resolved.

FTPClient f=FTPClient();

FTPClientConfig conf = new FTPClientConfig();
conf.setTimeZoneId("UTC");

f.configure(conf);

      



http://commons.apache.org/proper/commons-net/javadocs/api-3.3/org/apache/commons/net/ftp/FTPClientConfig.html

+2


source


Be careful, the function setTimeZoneId

has changed to setServerTimeZoneId

.



https://commons.apache.org/proper/commons-net/apidocs/org/apache/commons/net/ftp/FTPClientConfig.html

0


source







All Articles