小编use*_*947的帖子

无法成功传递字符串值"$ 10.55"作为弹簧路径变量

我的控制器类是

@RequestMapping(method = RequestMethod.POST, value = "/auditregistry/collectionentry/cid/{cid}/collid/{collid}/colldt/{collectiondate}/amount/{amt}")

public ModelAndView saveManualCollection(@PathVariable("cid") Integer custId, @PathVariable("collid") Integer collRtId, @PathVariable("collectiondate") String dt, **@PathVariable("amt") String amount**) throws Exception 
{
    debug("amount recieving=="+amount);
Run Code Online (Sandbox Code Playgroud)

我传递给网址的值是

/ auditregistry/collectionentry/cid/9991/collid/10/colldt/20120726/amount/$ 14.55

当我试图打印金额值打印为"14美元"而不是"14.55美元"我该怎么做才能打印实际价值"14.55美元"

任何帮助都非常感谢

java spring spring-mvc

3
推荐指数
2
解决办法
950
查看次数

将字符串转换为java中的日期格式为2012-07-27

我的输入字符串为2012-07-27,我希望输出为日期,但格式与2012-07-27相同

我的代码是

DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

    try {
        Date today = df.parse("20-12-2005");
        System.out.println("Today = " + df.format(today));

                 } catch (ParseException e) {
        e.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

我的输出是

Fri Jul 27 00:00:00 IST 2012
Run Code Online (Sandbox Code Playgroud)

但我想返回日期对象,如2012-07-26 23:59:59而不是字符串任何帮助请

任何帮助都非常感谢

java

1
推荐指数
1
解决办法
1690
查看次数

标签 统计

java ×2

spring ×1

spring-mvc ×1