Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>@kidmenot: Thanks for the link, but that solution requires to handle the javascript-date "manually" on the java side and to change the Javascript-side. So finally we needed to change the javascript-part only. There was</p> <pre class="lang-js prettyprint-override"><code>var myDate = new Date(): // ... many LOCs var myDateString = "" + myDate + ""; </code></pre> <p>scattered all over the js-code. So just changing that to</p> <pre class="lang-js prettyprint-override"><code>var myDate = new Date(): // ... many LOCs var myDateString = myDate; </code></pre> <p>solved the issue, because later on the was a</p> <pre><code>JSON.stringify() </code></pre> <p>just before sending it to the server. That <em>JSON.stringify()</em> calls <em>myDate.toJSON()</em> which returns an ISO-8601 datestring which gets processed by Jersey without the need for any further coding. </p> <p>So we chose this solution to spare us from future complications.</p> <p><strong>Edit half a year later:</strong></p> <p>This parse problem occured often and was finally inevitable because of some js-framework. The following is our Java-Solution:</p> <pre class="lang-java prettyprint-override"><code>public static Date jsDateStringToJavaDate(String jsDateString) throws ParseException{ String[] arrStrDateParts = jsDateString.split(" "); SimpleDateFormat sdf = new SimpleDateFormat("E MMM dd yyyy HH:mm:ss", Locale.ENGLISH); sdf.setTimeZone(TimeZone.getTimeZone(arrStrDateParts[5].substring(0,6)+":"+arrStrDateParts[5].substring(6))); return sdf.parse(arrStrDateParts[0]+" "+arrStrDateParts[1]+" "+arrStrDateParts[2]+" "+arrStrDateParts[3]+" "+arrStrDateParts[4]); } </code></pre> <p>If you got a better solution, please post it here. Thx</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload