{
Calendar cal = Calendar.getInstance();
cal.clear();
Date date = cal.getTime();
CellValueId cellValueID = new CellValueId(id, new Timestamp(date.getTime()));
CellValue cellValue = cellValueDAO.findById(cellValueID);
if(cellValue!=null)
result = cellValue.getValue();
}
else//day,month,year
{
if(reportType.equalsIgnoreCase("day"))
{
sdf = new SimpleDateFormat("yyyy-MM-dd");
}
else if(reportType.equalsIgnoreCase("month"))//月报,时间id为yyyy-MM-1
{
sdf = new SimpleDateFormat("yyyy-MM");
}
else if(reportType.equalsIgnoreCase("year"))//年报,时间id为yyyy-1-1
{
sdf = new SimpleDateFormat("yyyy");
}
String timeString = sdf.format(time);
try {
Date date = sdf.parse(timeString);//得到格式化的时间id
CellValueId cellValueID = new CellValueId(id, new Timestamp(date.getTime()));
CellValue cellValue = cellValueDAO.findById(cellValueID);
if(cellValue!=null)
result = cellValue.getValue();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}