public String progressbarDay(String pid) throws Exception {
FinanceProject fp = (FinanceProject)baseDao.selectOne("jz.finance.getFinanceProjectById",pid);
double sday = (fp.getEndDate().getTime()-fp.getStartDate().getTime())/(24*60*60*1000);//两个日期之间的天数,即总天数
double nday = (new Date().getTime()-fp.getStartDate().getTime())/(24*60*60*1000);//开始时间-现在的时间 = 项目已开始时间
return doubleTrans(DecimalFormat((nday/sday)*100));
}
public String progressbarMoney(String pid) throws Exception {
FinanceProject fp = (FinanceProject) baseDao.selectOne("jz.finance.getFinanceProjectById",pid);
Map map = new HashMap();
map.put("project", pid);
FinanceReserve fr = (FinanceReserve) baseDao.selectOne("getFinanceReserveForProjectListPay",map);
double money = (fr.getNum()*Double.parseDouble(fp.getOnePrice()));//已经筹集到的金额
return DecimalFormat((money/Double.parseDouble(fp.getMoney())*100));
}
//四舍五入保留小数点2位
private String DecimalFormat(double number){
String ret = null;
try {
DecimalFormat df = new DecimalFormat("#.00");
ret = df.format(number).toString();
} catch (Exception e) {
e.printStackTrace();
}
return ret;
}
//去掉double小数点后无效的0
public static String doubleTrans(double dou){
if(Math.round(dou)-dou==0){
return String.valueOf((long)dou);
}
return String.valueOf(dou);
}