Author: sebb
Date: Wed Dec 10 13:40:17 2014
New Revision: 1644402
URL: http://svn.apache.org/r1644402
Log:
Update to use mdtmFile
Modified:
commons/proper/net/trunk/src/main/java/examples/ftp/FTPClientExample.java
Modified:
commons/proper/net/trunk/src/main/java/examples/ftp/FTPClientExample.java
URL:
http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/examples/ftp/FTPClientExample.java?rev=1644402&r1=1644401&r2=1644402&view=diff
==============================================================================
--- commons/proper/net/trunk/src/main/java/examples/ftp/FTPClientExample.java
(original)
+++ commons/proper/net/trunk/src/main/java/examples/ftp/FTPClientExample.java
Wed Dec 10 13:40:17 2014
@@ -25,11 +25,6 @@ import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.UnknownHostException;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.TimeZone;
import org.apache.commons.net.PrintCommandListener;
import org.apache.commons.net.ftp.FTP;
@@ -375,10 +370,8 @@ __main:
}
}
if (mdtm) {
- FTPFile f = new FTPFile();
- f.setName(remote);
- String stamp = ftp.getModificationTime(remote);
- f.setTimestamp(parseGMTdate(stamp) ); // parse the
returned string
+ FTPFile f = ftp.mdtmFile(remote);
+ System.out.println(f.getRawListing());
System.out.println(f.toFormattedString(displayTimeZoneId));
}
if (mlst) {
@@ -518,29 +511,5 @@ __main:
}
};
}
-
- private static Calendar parseGMTdate(String gmtTimeStamp) {
- SimpleDateFormat sdf;
- final boolean hasMillis;
- if (gmtTimeStamp.contains(".")){
- sdf = new SimpleDateFormat("yyyyMMddHHmmss.SSS");
- hasMillis = true;
- } else {
- sdf = new SimpleDateFormat("yyyyMMddHHmmss");
- hasMillis = false;
- }
- TimeZone GMT = TimeZone.getTimeZone("GMT"); // both need to be set for
the parse to work OK
- sdf.setTimeZone(GMT);
- GregorianCalendar gc = new GregorianCalendar(GMT);
- try {
- gc.setTime(sdf.parse(gmtTimeStamp));
- if (!hasMillis) {
- gc.clear(Calendar.MILLISECOND);
- }
- } catch (ParseException e) {
- // TODO ??
- }
- return gc;
- }
}