date1.getTime()-date2.getTime() <= 5*24*60*60*1000
解决方案 »
- Java NIO 一直接收OP_ACCEPT的问题
- The method getMsg() from the type test1 is not visible
- struts,提交表单后,本机上一直保留表单的内容,怎么清除啊?
- 怎么把JTextArea中的内容导出到Excel文件中
- 对象数组的强型转换问题
- 请问如何使JTable里的每一列都不可拖拽而且不能改变列的宽度
- 怎样实现一个内部匿名类?
- 请问哪里有Java Tutorial中文版下载
- 我想问一下,我装了Jbuilder4之后,为什么没有关于Java document的帮助!
- 为什么在jbuilder3中编译的部分applet在浏览器中不能运行?
- 集合的交,并,和以及它们性能对比C的问题。
- 各位,请问怎么处理这样的多个关联数组,使其一一对应上?都进来看看,多谢了先!thanks
public boolean isStandardDate(String sourceString)
{
String date = sourceString;
if(date == null)
{
return false;
}
else if(date.length()!=8)
{
return false;
}
else if(!isNumber(date))
{
return false;
}
else
{
String year = date.substring(0,4);
String month = date.substring(4,6);
String day = date.substring(6,8);
if((month.compareTo("12")>0)||(month.compareTo("01")<0)||(day.compareTo("31")>0)||(day.compareTo("01")<0))
{
return false;
}
else
{
int Year = Integer.parseInt(year);
if(month.compareTo("08")<0)
{
if(month.equals("02"))
{
if((Year%4==0)&&((Year%100!=0))||(Year%400==0))
{
if(day.compareTo("29")>0)
{
return false;
}
else
{
return true;
}
}
else
{
if(day.compareTo("28")>0)
{
return false;
}
else
{
return true;
}
}
}
else
{
int Month = Integer.parseInt(month);
if(Month%2==0)
{
if(day.compareTo("30")>0)
{
return false;
}
else
{
return true;
}
}
else
{
return true;
}
}
}
else
{
int Month = Integer.parseInt(month);
if(Month%2==0)
{
return true;
}
else
{
if(day.compareTo("30")>0)
{
return false;
}
else
{
return true;
}
}
}
}
}
}
* @param sourceString
* @param addDays
*/
public String dateAdjust(String sourceString, int addDays)
{
String returnString = sourceString;
if(isStandardDate(sourceString))
{
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Date dt = sdf.parse(sourceString, new ParsePosition(0));
Calendar cal = Calendar.getInstance();
cal.setTime(dt);
cal.add(cal.DATE, addDays);
Date dt1 = cal.getTime();
StringBuffer strBuffer = new StringBuffer();
strBuffer.append("");
returnString = sdf.format(dt1, strBuffer, new FieldPosition(0)).toString();
}
return returnString;
}
try{
sdf.parse(strDate)
}catch(ParseException){}
try{
sdf.parse(strDate)
return true;
}catch(ParseException){
return false;
}