我正在使用 jQuery Datepicker,它提供像 07/05/2015 这样的格式的日期。我使用 simpledateformat 来格式化这个日期。但 SDF 总是将其转换为今天的日期。如何解决这个问题?
System.out.println("Activity IS : IS With Date");
SimpleDateFormat sdfOverTimeWithDate = new SimpleDateFormat("yyyy-MM-dd ");
Date startDate = ParamUtil.getDate(resourceRequest, "startDate", sdfOverTimeWithDate);
Date endDate = ParamUtil.getDate(resourceRequest, "endDate", sdfOverTimeWithDate);
int jobId= ParamUtil.getInteger(resourceRequest, "jobId");
System.out.println("jobId :"+jobId);
System.out.println("startDate :"+startDate);
System.out.println("endDate :"+endDate);
这个 statDate 和 endDate 仅给出今天的日期,而我要发送的日期格式为 07/05/2015。如何解决这个问题?请有人帮忙
最佳答案
您将错误的日期格式传递给 SimpleDateFormat
构造函数。尝试使用 "dd/MM/yyyy"
而不是 "yyyy-MM-dd "
关于java - 如何使用 SimpleDateFormat 格式化 jQuery 日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31919207/