Restful Webservices PostforObject一个对象和一个日期参数

时间:2017-05-09 19:55:26

标签: java rest

我搜索了很多可能性,但没有任何效果,这是我的最后一次尝试。 在这里,我调用Requestmapping。

buf_data.size() is 140050

这是我想给列表中包含对象和日期的方法。

private static double exampleMethod(List<Cashflow> cashflowList, Date date) {
    RestTemplate restTemplate = new RestTemplate();
    String url = "http://localhost:9080/example/method";
    Map<String, String> verbar = new HashMap<String, Double>();
    verbar.put("date", date);

    return restTemplate.postForObject(url, cashflowList, Double.class, verbar);
}

我尝试的所有内容都以此错误结束。谢谢你的帮助。 :)

    @RequestMapping(value = "/verbarwertung", params = { "date"}, method = RequestMethod.POST)  
@ResponseBody   
public double verbarwertung(@RequestParam("date") Date datum, @RequestBody List<Cashflow> cashflowList) {

    double cashflow = 0;
    double datumDiff = 0;
    TimeUnit timeunit = TimeUnit.DAYS;
    Calendar cal = Calendar.getInstance();
    Calendar cal2 = Calendar.getInstance();
    cal2.setTime(datum);
    for (int i = 0; i < cashflowList.size(); i++) {
        cal.setTime(cashflowList.get(i).getDatum());
        if (cal.get(Calendar.MONTH) == cal2.get(Calendar.MONTH) && cal.get(Calendar.YEAR) == cal2.get(Calendar.YEAR)) {
            cashflow = cashflowList.get(i).getCashflow();
            long diffInMillies = cashflowList.get(cashflowList.size() - 1).getDatum().getTime()
                        - cashflowList.get(i).getDatum().getTime();
            double restLaufzeit = timeunit.convert(diffInMillies, TimeUnit.MILLISECONDS);
            datumDiff = restLaufzeit / 365;    
        }
    }


    double barwert;

    barwert = cashflowList.get() / Math.pow(1 + zins, datumDiff);

    return barwert;     
}

0 个答案:

没有答案