资源简介
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
相关资源
- tomcat5.5解压版
- org.apache.commons jar包
- 使用JSP+jqueryUI+java Servlet通过Apache PO
- Apache Tomcat6.0 64位(安装版和免安装版
- Apache Tomcat 6
- 利用apache-apollo-1.7.1创建MQTT broker和服
- Apache-cxf 2.2.8压缩包
- apache-tomcat-10.0.0-M6.exe
- apache-common jar包
- android 通过ftp协议访问服务器上的目录
- org.apache.commons中的各种jar包
- apache-cxf-2.5.9
- apache-tomcat-6.0.53版本32位和64位
- Apache commons API(整套全版
- IOUtils(包含apache全部的commons jar包)
- apache-jmeter-3.0
- Android端连接ftp服务器浏览资源目录
- Apache实现文件解压缩
- Apache Commons官网下的jar包
- android ftp上传
- orgapache_commons
- apache-groovy-sdk-2.4.16
- apache-jmeter-5.2.1.zip
- apache-activemq-5.16.0-bin-windows.zip----wind
- apache-jmeter-5.1.1(Requires Java 8+).zip
- spark apache日志分析、流数据处理教程
- apache.soap jar包
- java Excel数据导出,HSSH、 XSSF、SXSSF、
- 详解Java使用Jsch与sftp服务器实现ssh免
- org.apache.commons.net.ftp.FTPClient jar包下载
评论
共有 条评论