求教:让人郁闷的时间问题

求教:让人郁闷的时间问题

遇到了一个很棘手的问题,Hibernate查询时,附带查询条件,下面是使用到的查询语句:select a.AURE_INVEST,c.ENGI_COST,c.EQUI_COST,c.DEMO_COST,c.TWOCL_COST,c.NOTE_COST,c.INTEREST_COST,sum(cast(c.FUNDS_PAID as float)) as sumGovPay,sum(cast(e.FUNDS_IN as float)) as lastMonthArrive,sum(cast(c.FUNDS_PAID as float)) as lastMonthPay,f.QUARTER1_BUDGET,f.QUARTER2_BUDGET,f.QUARTER3_BUDGET,f.QUARTER4_BUDGET,sum(cast(c.FUNDS_PAID as float)) as thisQuarterPay,f.ID,f.PROJ_CODE,b.PROJ_TYPE,b.PROJ_NAME,b.PROJ_SORT,b.PROJ_STAT,b.P_RECORD_TIME from GOV_CODE a,PROJ_CODE b,PROJ_FUNDS_PAID c,PROJ_FUNDS_SOURCE e,PROJ_YEAR_BUDGET f where e.DATA_YEAR<'"+year+"' and e.DATA_MONTH<'"+month+"' and c.DATA_DATE<"+DataParser.formatStringDate(newDate)+" and f.DATA_YEAR='"+year+"' and c.DATA_DATE>="+DataParser.formatStringDate(year+"-"+"10-01 00:00:00")+" and c.DATA_DATE<="+DataParser.formatStringDate(year+"-"+"12-31 00:00:00")+" and a.GOV_CODE=b.GOV_CODE and c.PROJ_CODE=b.PROJ_CODE and f.PROJ_CODE=b.PROJ_CODE and e.PROJ_CODE=b.PROJ_CODE group by a.AURE_INVEST,c.ENGI_COST,c.EQUI_COST,c.DEMO_COST,c.TWOCL_COST,c.NOTE_COST,c.INTEREST_COST,
f.QUARTER1_BUDGET,f.QUARTER2_BUDGET,f.QUARTER3_BUDGET,f.QUARTER4_BUDGET,f.ID,f.PROJ_CODE,b.PROJ_TYPE,
b.PROJ_NAME,b.PROJ_SORT,b.PROJ_STAT,b.P_RECORD_TIME
其中DATA_YEAR和DATA_MONTH在数据库中的存储类型是String型,  DATA_DATE存储的类型是Date型,使用到的DataParser.formatStringDate方法如下:
 public static Date formatStringDate(String sDate)
 {
  DateFormat df = new SimpleDateFormat("yyyy-MM-dd 00:00:00");
  Date tDate = null;
  try {
   tDate = df.parse(sDate);
  } catch (ParseException e) {
   e.printStackTrace();
  }
  return tDate;
 }
但是无论如何都是出不来结果,报的是一个Not all named parameters have been set: [00:00]的错误,格式化出来的时间也不是想要的类型,而是这个衰样:Sat Nov 01 00:00:00 CST 2008,与我想要的“yyyy-MM-dd hh:mm:ss”相去甚远,不知道该怎么格式化一下,麻烦那位高手指点一下,感激不尽!

你可能感兴趣的:(求教:让人郁闷的时间问题)