如何在 Spring WebFlow2 中检查日期格式。
我正在尝试找到一些可以与 Spring Webflow 一起使用的代码来检查用户输入的日期是否有效。我认为这是一个简单的检查
最佳答案
在客户端使用 JavaScript 正则表达式,在服务器端使用 java.text.DateFormat
:
DateFormat formatter = new SimpleDateFormat("yyyy-MMM-dd");
formatter.setLenient(false);
String dateAsString = request.getParameter("date");
Date date = formatter.parse(dateAsString); // throws an exception if the String is incorrectly formatted.
关于java - 如何在 Spring WebFlow2 中检查日期格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12267386/