资源简介
http://blog.csdn.net/wangchsh2008/article/details/47101423的附件

代码片段和文件信息
/**
*
*/
package com.zznode.tnms.ra.c11n.nj.resource.ftp;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import org.apache.commons.net.ftp.parser.FTPTimestampParserImpl;
/**
* @desc: 此类的原始贡献者为hzwei206,
* 解决apache ftp中文语言环境下,
* FTPClient.listFiles()为空的bug
* @author
* @since 2015-7-27
*/
public class FTPTimestampParserImplExZH extends FTPTimestampParserImpl {
private SimpleDateFormat defaultDateFormat = new SimpleDateFormat(“mm d hh:mm“);
private SimpleDateFormat recentDateFormat = new SimpleDateFormat(“yyyy mm d“);
/**
* @author hzwei206 将中文环境的时间格式进行转换
*/
private String formatDate_Zh2En(String timeStrZh) {
if (timeStrZh == null) {
return ““;
}
int len = timeStrZh.length();
StringBuffer sb = new StringBuffer(len);
char ch = ‘ ‘;
for (int i = 0; i < len; i++) {
ch = timeStrZh.charAt(i);
if ((ch >= ‘0‘ && ch <= ‘9‘) || ch == ‘ ‘ || ch == ‘:‘) {
sb.append(ch);
}
}
return sb.toString();
}
/**
* 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 org.apache.commons.net.ftp.parser.FTPTimestampParser#parseTimestamp(java.lang.String)
*/
public Calendar parseTimestamp(String timestampStr) throws ParseException {
timestampStr = formatDate_Zh2En(timestampStr);
Calendar now = Calendar.getInstance();
now.setTimeZone(this.getServerTimeZone());
Calendar working = Calendar.getInstance();
working.setTimeZone(this.getServerTimeZone());
ParsePosition pp = new ParsePosition(0);
Date parsed = null;
if (this.recentDateFormat != null) {
parsed = recentDateFormat.parse(timestampStr pp);
}
if (parsed != null && pp.getIndex() == timestampStr.length()) {
working.setTime(parsed);
working.set(Calendar.YEAR now.get(Calendar.YEAR));
if (working.after(now)) {
working.add(Calendar.YEAR -1);
}
} else {
pp = new ParsePosition(0);
parsed = defaultDateFormat.parse(timestampStr pp);
// note length checks are mandatory for us since
// SimpleDateFormat methods will succeed if less than
// full string is matched. They will also accept
// despite “leniency“ setting a two-digit number as
// a valid year (e.g. 22:04 will parse as 22 A.D.)
// so could mistakenly confuse an hour with a year
// if we don‘t insist on full length parsing.
if (parsed != null && pp.getIndex() == timestampStr.length()) {
working.setTime(parsed);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 11362 2015-07-28 10:09 UnixFTPEntryParser.java
文件 3233 2015-07-27 23:17 FTPTimestampParserImplExZH.java
----------- --------- ---------- ----- ----
14595 2
相关资源
- java远程进行telnetftpssh连接的方法及源
- android 安卓 FTP 文件 管理
- apache-tomcat-7.0.86.tar.gz
- JAVA org包
- ftp暴力破解源码(java双击运行)
- 2018年org.apache.commons.io jar包
- apache httpclient jar包
- java org.common 开发,引用
- ApacheJMeter_http.jar与ApacheJMeter_core.jar.
- org.apache.poi JAR包 Java
- 课程设计基于GUI的FTP客户端JAVA源码
- Java Socket 模拟 Ftp Server/Client
- apache-tomcat-7.0.63-windows-x64.zip
- java实现Ftp批量文件及解压
- apache-tomcat-6.0.32
- apache-maven-3.3.9-bin
- android ftp 上传文件 demo
- apache-tomcat-8.5.20.tar.gz
- apache-tomcat-8.5.16
- 基于java的FTP客户端设计与实现
- apache-tomcat-6.0.43.rar
- Android ftp断点续传Demo
- apache-ant-1.9.4-bin
- apache-tomcat-8.0.32-windows-x64 64位
- org.apache.tools.*需要的ant.jar包
- org.apache.jasper 的jar包
- apache-tomcat-9.0.14
- apache-tomcat-8.0.51
- apache-maven-3.3.9.zip
- Android FTP 上传/ 带进度条精简DEMO
评论
共有 条评论