0

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>
aswathy
  • 821
  • 3
  • 15
  • 27
  • In this case I have to assign date, which is inside the returned arraylist, to a textbox. The arraylist is returned inside script, ie a jquery ajax call to servlet and also it is in json format. data[0].demo_planned_on is the date returned and format is all wrong. How do I use this particular object and covert it to required format and assign it to textbox. There must be an answer specific to this. – aswathy Jun 07 '16 at 07:16
  • Looking at the already existing question did not help in this case – aswathy Jun 07 '16 at 07:18

0 Answers0