I'm converting objects to JSON string using Gson from a servlet and passing it to a jsp page. But the format in which I get the date in the jsp page is (month date,year). I need yyyy-MM-dd format. How can I change the default format to the format that I need?
servlet side:
CustDAO cusName=new CustDAO();
ArrayList<Cust> list2=cusName.dispCustomer2(abcd);
new Gson().toJson(list2, response.getWriter());
jsp side:
<script>
$(document).ready(function(){
var selected;
$('#selectUsers').change(function(){
selected = $('#selectUsers').val();
$.ajax({
url: "Servlet2",
type: "Post",
data: {"selectUsers":selected},
dataType: "json",
success : function(data)
{
$('#dpo').val(data[0].demo_planned_on);
$('#dao').val(data[0].demo_actual_on);
}
});
});
</script>