[code="java"][/code][code="java"]System.out.println("common中的date1:"+fileForm.getDate1());
System.out.println("common中的date2:"+fileForm.getDate2());
System.out.println("fileForm.getDate1() != null的值:"+(fileForm.getDate1() != null));
System.out.println("fileForm.getDate2() != null的值:"+(fileForm.getDate2() != null));
System.out.println("common中的date2的值:"+fileForm.getDate2());
try {
spx = new SqlParameterExt();
if (fileForm.getDate1() != null && !"".equals(fileForm.getDate1())) {
System.out.println("第一个时间不为空");
if (fileForm.getDate2() != null && !"".equals(fileForm.getDate2())) {
System.out.println("第一个时间不为空,第二个时间也不为空");
// 前后时间都不为空
// Sybase数据库中,查询时间区间时,不包括后面的时间点,
// 因此查询时,将后面的时间点多加一天 (60*60*24*1000一天的毫秒数)
SimpleDateFormat dateFormat = new SimpleDateFormat(
"yyyy-MM-dd");
long lo = dateFormat.parse(fileForm.getDate2()).getTime();
lo = lo + 60 * 60 * 24 * 1000;
Date d = new Date(lo);
String Date2 = dateFormat.format(d);
sql = sql + " where a.tqrq between '" + fileForm.getDate1()
+ "' and '" + Date2 + "' ";
System.out.println("第一个时间不为空,第二个时间也不为空");
} else{
System.out.println("第一个时间不为空,第二个时间为空");
// 后时间为空
// Sybase数据库中,查询时间区间时,不包括后面的时间点,
// 因此查询时,将后面的时间点多加一天 (60*60*24*1000一天的毫秒数)
SimpleDateFormat dateFormat = new SimpleDateFormat(
"yyyy-MM-dd");
long lo = dateFormat.parse(DateUtils.getCurDate())
.getTime();
lo = lo + 60 * 60 * 24;
Date d = new Date(lo);
String Date2 = dateFormat.format(d);
sql = sql + " where a.tqrq between '" + fileForm.getDate1()
+ "' and '" + Date2 + "' ";
}
}
//sql = sql + " order by a.tqbh desc";
} catch (Exception err) {
// throw new CallDbException("参数不合法!" + err.getMessage());
System.out.println(err.getMessage());
}
sql = sql + " order by a.tqbh desc";[/code]
输出结果很让人纳闷
中间有两句
[code="java"]System.out.println("fileForm.getDate2() != null的值:"+(fileForm.getDate2() != null));
System.out.println("common中的date2的值:"+fileForm.getDate2());[/code]
输出结果很怎么会是这样的?
[color=red]fileForm.getDate2() != null的值:true
common中的date2的值:null[/color]