package com.crop.util;
import java.sql.Timestamp;
import java.text.DateFormatSymbols;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Enumeration;
import java.util.GregorianCalendar;
import java.util.Hashtable;
import java.util.Locale;
import org.apache.commons.lang.StringUtils;
/**
* <p>鍏叡鏂规硶绫?</p>
* <p>鎻愪緵鏈夊叧鏃ユ湡鐨勫疄鐢ㄦ柟娉曢泦</p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: NineTowns</p>
* @author Weiwenqi
* @version 1.0
*
*/
public class DateUtil
{
static java.text.SimpleDateFormat sdfShort = new java.text.SimpleDateFormat("yyyyMMdd");
static java.text.SimpleDateFormat sdfLong = new java.text.SimpleDateFormat("yyyy-MM-dd");
static java.text.SimpleDateFormat sdfLongCn = new java.text.SimpleDateFormat("yyyy骞碝M鏈坉d鏃?");
static java.text.SimpleDateFormat sdfShortU = new java.text.SimpleDateFormat("MMM dd",Locale.ENGLISH);
static java.text.SimpleDateFormat sdfLongU = new java.text.SimpleDateFormat("MMM dd,yyyy",Locale.ENGLISH);
static java.text.SimpleDateFormat sdfLongTime = new java.text.SimpleDateFormat("yyyyMMddHHmmss");
static java.text.SimpleDateFormat sdfLongTimePlus = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
static java.text.SimpleDateFormat sdfShortLongTimePlusCn = new java.text.SimpleDateFormat("yyyy骞碝M鏈坉d鏃? HH:mm");
static java.text.SimpleDateFormat sdfLongTimePlusMill = new java.text.SimpleDateFormat("yyyyMMddHHmmssSSSS");
static java.text.SimpleDateFormat sdfMd = new java.text.SimpleDateFormat("MM鏈坉d鏃?");
private static long DAY_IN_MILLISECOND = 0x5265c00L;
public DateUtil()
{
}
/**
* @author Pablo
* Descrption:取锟矫碉拷前锟斤拷锟斤拷getgetg get Date format Example锛?2008-05-15
* @return String
* @throws java.lang.Exception
*/
public static String getDateLong(Date date)
{
String nowDate = "";
try
{
if(date != null)
nowDate = sdfLong.format(date);
return nowDate;
}
catch (Exception e)
{
System.out.println("Error at getDate:" + e.getMessage());
return "";
}
}
/**
* @author Pablo
* Descrption:取锟矫碉拷前锟斤拷锟斤拷getgetg get Date format Example锛?2008骞?-05鏈?-15鏃?
* @return String
* @throws java.lang.Exception
*/
public static String getDateLongCn(Date date)
{
String nowDate = "";
try
{
if(date != null)
nowDate = sdfLongCn.format(date);
return nowDate;
}
catch (Exception e)
{
System.out.println("Error at getDate:" + e.getMessage());
return "";
}
}
/**
* @author vowo
* Descrption:取锟矫碉拷前锟斤拷锟斤拷getgetg get Date format Example锛?05鏈?-15鏃?
* @return String
* @throws java.lang.Exception
*/
public static String getDateMD(Date date)
{
String nowDate = "";
try
{
if(date != null)
nowDate = sdfMd.format(date);
return nowDate;
}
catch (Exception e)
{
System.out.println("Error at getDate:" + e.getMessage());
return "";
}
}
/**
* @author Pablo
* Descrption:取锟矫碉拷前锟斤拷锟斤拷getgetg get Date format Example锛?2008骞?-05鏈?-15鏃? 11:05
* @return String
* @throws java.lang.Exception
*/
public static String getDateShortLongTimeCn(Date date)
{
String nowDate = "";
try
{
if(date != null)
nowDate = sdfShortLongTimePlusCn.format(date);
return nowDate;
}
catch (Exception e)
{
System.out.println("Error at getDate:" + e.getMessage());
return "";
}
}
/**
* @author Pablo
* Descrption:取锟矫碉拷前锟斤拷锟斤拷getgetg get Date format Example锛欰ug 28, 2007
* @return String
* @throws java.lang.Exception
*/
public static String getDateUS(Date date)
{
String nowDate = "";
try
{
if(date != null)
nowDate = sdfLongU.format(date);
return nowDate;
}
catch (Exception e)
{
System.out.println("Error at getDate:" + e.getMessage());
return "";
}
}
/**
* @author Pablo
* Descrption:取锟矫碉拷前锟斤拷锟斤拷getgetg get Date format Example锛欰ug 28, 2007
* @return String
* @throws java.lang.Exception
*/
public static String getDateUSShort(Date date)
{
String nowDate = "";
try
{
if(date != null)
nowDate = sdfShortU.format(date);
return nowDate;
}
catch (Exception e)
{
System.out.println("Error at getDate:" + e.getMessage());
return "";
}
}
/**
* 绠?鍗曡浆鎹㈡棩鏈熺被鍨嬪埌瀛楃涓茬被鍨嬶紝鏈湴淇℃伅璁句负UK
*
* @param date
* @param format
* @return String
*/
public static String getFomartDate(Date date, String format)
{
try
{
return new SimpleDateFormat(format, Locale.UK).format(date);
}
catch (Exception e)
{
e.printStackTrace();
return (date == null) ? new Date().toString() : date.toString();
}
}
/**
* Descrption:鍙栧緱褰撳墠鏃ユ湡鏃堕棿,鏍煎紡涓?:YYYYMMDDHHMISS
* @return String
* @throws java.lang.Exception
*/
public static String getNowLongTime() throws Exception
{
String nowTime = "";
try
{
java.sql.Date date = null;
date = new java.sql.Date(new java.util.Date().getTime());
nowTime = sdfLongTime.format(date);
return nowTime;
}
catch (Exception e)
{
throw e;
}
}
/**
* Descrption:鍙栧緱褰撳墠鏃ユ湡,鏍煎紡涓?:YYYYMMDD
* @return String
* @throws java.lang.Exception
*/
public static String getNowShortDate() throws Exception
{
String nowDate = "";
try
{
java.sql.Date date = null;
date = new java.sql.Date(new java.util.Date().getTime());
nowDate = sdfShort.format(date);
return nowDate;
}
catch (Exception e)
{
throw e;
}
}
/**
* Descrption:鍙栧緱褰撳墠鏃ユ湡,鏍煎紡涓?:YYYY-MM-DD
* @return String
* @throws java.lang.Exception
*/
public static String getNowFormateDate() throws Exception
{
String nowDate = "";
try
{
java.sql.Date date = null;
date = new java.sql.Date(new java.util.Date().getTime());
nowDate = sdfLong.format(date);
return nowDate;
}
catch (Exception e)
{
throw e;
}
}
/**
* Descrption:鍙栧緱褰撳墠鏃ユ湡,鏍煎紡涓?:yyyy-MM-dd HH:mm:ss
* @return String
* @throws java.lang.Exception
*/
public static String getNowPlusTime() throws Exception
{
String nowDate = "";
try
{
java.sql.Date date = null;
date = new java.sql.Date(new java.util.Date().getTime());
nowDate = sdfLongTimePlus.format(date);
return nowDate;
}
catch (Exception e)
{
throw e;
}
}
/**
* Descrption:鍙栧緱褰撳墠鏃ユ湡,鏍煎紡涓?:yyyy-MM-dd HH:mm:ss
* @return String
* @throws java.lang.Exception
*/
public static String getPlusTime(Date date) throws Exception
{
if(date == null ) return null;
try
{
String nowDate = sdfLongTimePlus.format(date);
return nowDate;
}
catch (Exception e)
{
throw e;
}
}
/**
* Descrption:鍙栧緱褰撳墠鏃ユ湡,鏍煎紡涓?:yyyy-MM-dd HH:mm:ss
* @return String
* @throws java.lang.Exception
*/
public static String getPlusTime2(Date date)
{
if(date == null ) return null;
try
{
String nowDate = sdfLongTimePlus.format(date);
return nowDate;
}
catch (Exception e)
{
e.printStackTrace();
}
return "";
}
/**
* Descrption:鍙栧緱褰撳墠鏃ユ湡鍒版绉掓瀬,鏍煎紡涓?:yyyyMMddHHmmssSSSS
* @return String
* @throws java.lang.Exception
*/
public static String getNowPlusTimeMill() throws Exception
{
String nowDate = "";
try
{
java.sql.Date date = null;
date = new java.sql.Date(new java.util.Date().getTime());
nowDate = sdfLongTimePlusMill.format(date);
return nowDate;
}
catch (Exception e)
{
throw e;
}
}
/**
* 寰楀埌褰撳墠骞翠唤鍊?:1900
* @return String
* @throws java.lang.Exception
*/
publi
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
crop.rar (71个子文件)
crop
.project 1KB
WebContent
WEB-INF
lib
commons-collections-3.2.jar 558KB
commons-fileupload-1.3.1.jar 67KB
json-lib-2.2-jdk15.jar 131KB
json.jar 45KB
commons-lang-2.4.jar 256KB
org.json.jar 117KB
commons-httpclient-3.0.1.jar 273KB
commons-beanutils-1.7.0.jar 184KB
ezmorph-1.0.3.jar 76KB
jsoup-1.6.3.jar 270KB
json_simple-1.1.jar 16KB
commons-io-2.4.jar 181KB
commons-codec-1.9.jar 258KB
commons-logging-1.0.4.jar 37KB
mysql-connector-java-3.1.12-bin.jar 436KB
web.xml 1KB
index.jsp 2KB
croppic.js 30KB
assets
.DS_Store 6KB
img
jobotic.png 6KB
.DS_Store 6KB
night.jpg 186KB
placeholder.png 6KB
downloadIcon.png 13KB
cropperIcons.png 4KB
jobotic_bubble.png 2KB
headerBg.jpg 413KB
logo.png 7KB
steinlinconsulting.png 3KB
studio42.png 2KB
park_view.jpg 55KB
js
.DS_Store 6KB
main.js 1KB
jquery-1.11.0.min.js 94KB
jquery.mousewheel.min.js 3KB
bootstrap.min.js 27KB
fonts
glyphicons-halflings-regular.ttf 40KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.svg 61KB
glyphicons-halflings-regular.woff 23KB
css
.DS_Store 6KB
croppic.css 5KB
crop_main.css 5KB
bootstrap.css 127KB
META-INF
MANIFEST.MF 39B
temp
src
com
crop
web
img_crop_to_file.java 5KB
img_crop.java 3KB
util
json
JSONUtil.java 8KB
JSONStringObject.java 417B
StringUtil.java 27KB
HtmlUtil.java 1KB
ImgUtils.java 5KB
JsonUtil.java 804B
DateUtil.java 77KB
.settings
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.common.project.facet.core.xml 345B
org.eclipse.jdt.core.prefs 395B
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.component 440B
.jsdtscope 503B
build
classes
com
crop
web
img_crop_to_file.class 6KB
img_crop.class 4KB
util
StringUtil.class 15KB
JsonUtil.class 1KB
HtmlUtil.class 2KB
ImgUtils.class 5KB
json
JSONUtil.class 5KB
JSONStringObject.class 617B
DateUtil.class 39KB
.classpath 841B
共 71 条
- 1
资源评论
lrq496
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功