I am trying to create an arraylist with three dates. I then want to save the arraylist into variable in a formatted way. However, when I try to document.write the variable, the elements are completely different.
<script>
<% List<String> strList = new ArrayList<String>();
strList.add("23-2-2016");
strList.add("24-2-2016");
strList.add("25-2-2016"); %>
var unavailableDates = [<% for (int i = 0; i < strList.size(); i++) { %><%= strList.get(i) %><%= i + 1 < strList.size() ? ",":"" %><% } %>];
document.write(unavailableDates);
</script>
The result I want is "23-2-2016", "24-2-2016", "25-2-2016".
However, I am getting this displayed: -1995,-1994,-1993