资源简介
java大文件上传至ftp服务器带进度条显示的,进度条的显示和ftp的上传速度同步,解决了进度条显示和ftp不同步的问题
代码片段和文件信息
package ftp;
import java.io.File;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class DateUtil {
private static Log log = LogFactory.getLog(DateUtil.class);
private static String defaultDatePattern = “yyyy-MM-dd HH:mm:ss“;
private static String datePattern = “yyyyMMdd“;
public static final int START_DATE = 1;
public static final int END_DATE = 2;
private static String timePattern = “HH:mm“;
private static String timePattern2 = “HH:mm:ss“;
public static Date getFirstDayOfMonth(Date date) {
return getCalendarDate(START_DATE date true);
}
public static Date getLastDayOfMonth(Date date) {
return getCalendarDate(END_DATE date true);
}
/**
* 取得日程管理查询日期 for spp
*
* @param type
* @param date
* @param tuncate
* @return
*/
private static Date getCalendarDate(int type Date date boolean truncate) {
Calendar rightNow = Calendar.getInstance(Locale.CHINA);
rightNow.setTime(date);
int base = 1;
switch (type) {
case END_DATE:
base = 0;
rightNow.add(Calendar.MONTH 1);
if (!truncate) {
break;
}
case START_DATE:
rightNow.add(Calendar.DAY_OF_MONTH base
- rightNow.get(Calendar.DAY_OF_MONTH));
break;
default:
break;
}
return rightNow.getTime();
}
/**
* Return default datePattern (MM/dd/yyyy)
*
* @return a string representing the date pattern on the UI
*/
public static String getDefaultDatePattern() {
return defaultDatePattern;
}
public static String getDatePattern() {
return datePattern;
}
/**
* This method attempts to convert an Oracle-formatted date in the form
* dd-MMM-yyyy to mm/dd/yyyy.
*
* @param aDate
* date from database as a string
* @return formatted string for the ui
*/
public static final String getDate(Date aDate) {
SimpleDateFormat df = null;
String returnValue = ““;
if (aDate != null) {
df = new SimpleDateFormat(getDefaultDatePattern());
returnValue = df.format(aDate);
}
return (returnValue);
}
public static final String getDate_yyyyMMdd(Date aDate) {
SimpleDateFormat df = null;
String returnValue = ““;
if (aDate != null) {
df = new SimpleDateFormat(getDatePattern());
returnValue = df.format(aDate);
}
return (returnValue);
}
/**
* This method generates a string representation of a date/time in the
* format you specify on input
*
* @param aMask
* the date pattern the string is in
* @param strDate
* a string representation of a date
* @return a converted Date object
* @see java.text.SimpleDateFormat
* @throws ParseException
*/
public static final D
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 932 2012-11-20 13:42 uploadProgress\.classpath
文件 315 2012-11-16 15:19 uploadProgress\.myme
文件 1420 2012-09-13 15:36 uploadProgress\.project
文件 500 2012-09-13 15:36 uploadProgress\.settings\.jsdtscope
文件 88 2012-09-13 15:34 uploadProgress\.settings\org.eclipse.core.resources.prefs
文件 49 2012-09-13 15:36 uploadProgress\.settings\org.eclipse.wst.jsdt.ui.superType.container
文件 6 2012-09-13 15:36 uploadProgress\.settings\org.eclipse.wst.jsdt.ui.superType.name
文件 16198 2012-11-16 16:52 uploadProgress\src\ftp\DateUtil.java
文件 384 2012-11-16 16:43 uploadProgress\src\ftp\FileInfo.java
文件 1169 2012-11-16 16:46 uploadProgress\src\ftp\PropertyReader.java
文件 15677 2012-11-20 12:37 uploadProgress\src\ftp\UploadFile.java
文件 904 2012-11-20 13:35 uploadProgress\src\lc\progress\myProgressListener.java
文件 1130 2009-08-03 12:38 uploadProgress\src\lc\progress\progressServlet.java
文件 2409 2012-11-20 13:43 uploadProgress\src\lc\progress\uploadServlet.java
文件 633 2009-08-02 19:14 uploadProgress\src\lc\progress\vo\fileUploadStatus.java
文件 110 2012-11-20 13:41 uploadProgress\src\wltx.properties
文件 442 2009-08-03 11:45 uploadProgress\WebRoot\css\progressBar.css
文件 1173 2009-08-03 12:50 uploadProgress\WebRoot\index.jsp
文件 56817 2009-08-02 18:06 uploadProgress\WebRoot\js\jquery-1.3.2.min.js
文件 2923 2012-11-20 13:48 uploadProgress\WebRoot\js\progressBar.js
文件 39 2009-08-02 17:33 uploadProgress\WebRoot\me
文件 11085 2012-11-20 13:42 uploadProgress\WebRoot\WEB-INF\classes\ftp\DateUtil.class
文件 729 2012-11-20 13:42 uploadProgress\WebRoot\WEB-INF\classes\ftp\FileInfo.class
文件 2312 2012-11-20 13:42 uploadProgress\WebRoot\WEB-INF\classes\ftp\PropertyReader.class
文件 16457 2012-11-20 13:42 uploadProgress\WebRoot\WEB-INF\classes\ftp\UploadFile.class
文件 1192 2012-11-20 13:42 uploadProgress\WebRoot\WEB-INF\classes\lc\progress\myProgressListener.class
文件 2017 2012-11-20 13:42 uploadProgress\WebRoot\WEB-INF\classes\lc\progress\progressServlet.class
文件 3623 2012-11-20 13:43 uploadProgress\WebRoot\WEB-INF\classes\lc\progress\uploadServlet.class
文件 1013 2012-11-20 13:42 uploadProgress\WebRoot\WEB-INF\classes\lc\progress\vo\fileUploadStatus.class
文件 110 2012-11-20 13:41 uploadProgress\WebRoot\WEB-INF\classes\wltx.properties
............此处省略28个文件信息
评论
共有 条评论