我有一个函数调用特定的日期格式。例如,仅当格式为
时2002-09-04 16:45:40
然后该功能将起作用。否则,它将返回错误消息,例如
"Format incorrect"
我想知道如何实现它?
答案 0 :(得分:5)
试试这个:
RequestMapping("/stuf/**")
public String test(HttpServletRequest request)
{
StringBuffer requestURL = request.getRequestURL();
// Do whatever you want with the url now
}
答案 1 :(得分:1)
好吧,您可以使用指定as.Date
参数的format
函数编写一个函数来检查您发送的日期输入的格式
checkDateFormat <- function(input) {
x <- as.Date(input, format= "%Y-%m-%d %H:%M:%S" )
if(is.na(x))
"Format incorrect"
else
"Format correct"
}
checkDateFormat("2002-09-04 16:45:40")
#[1] "Format correct"
checkDateFormat("2002-09-04")
#[1] "Format incorrect"
checkDateFormat("2002-09-04 16:45")
#[1] "Format incorrect"