Answer the question
In order to leave comments, you need to log in
How to return an object of type java.util.Date from JavaScript?
The Javascript calls a Java method that accepts a java.util.Date
. On the Java side, the code cannot be changed in any way. How can you generate a Java date object (even if it's empty) using Javascript?
Answer the question
In order to leave comments, you need to log in
Let's say you entered a date in <,input> on a "js" page:
<,input id="date" class="form-control" type="text">
further:
<,script type="text/javascript">
____vardate = $("#date").val();
____var formatDate = new Date(date);
<,/script>
After that you can pass formatDate (e.g. ajax) to java in "controller" and java will take it as a date:
//Spring using
@RequestMapping(method = RequestMethod.POST, value = "/your URL" )
@ResponseBody
public List methodName(
@RequestParam(value = "formatDate"
return contractList;
}
...but it will work in the case that Skeeeve is talking about
PS anyd3v hello from Odessa))
No way. You need a converter and the required format in which your Java application can understand the date, and form it on the js side.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question