Convert this kind of date format [Tue Mar 04 2014 00:00:00 GMT+0530 (Sri Lanka Standard Time) ] to Java Date Object

感情迁移 提交于 2019-12-13 05:15:37

问题


I'm using Jquery FullCalendar and It has a method to be called when a date cell event click.

dayClick: function(date, allDay, jsEvent, view) 
{
    if (allDay)
    {
        alert('Clicked on the entire day: ' + date);
    }else
    {
        alert('Clicked on the slot: ' + date);
    }
}

It's kinda like above. But the date it prints or it has in date is like this. Tue Mar 04 2014 00:00:00 GMT+0530 (Sri Lanka Standard Time)

How can I convert this kinda formatted string to a Java Date object. When i parse it it will through a parseException. I need to get a Java Date object which has the format of yyyy-MM-dd

Updated : Basically I need to convert a date string of format Tue Mar 04 2014 00:00:00 GMT+0530 (Sri Lanka Standard Time) To a Java Date object. (specifically in format yyyy-MM-dd)


回答1:


Basically I wanted to change the format of the FullCalendar date object. I achieved that by the following.

The date has the following format by default. Tue Mar 04 2014 00:00:00 GMT+0530 (Sri Lanka Standard Time)

var dd = $.fullCalendar.formatDate(date,"yyyy-MM-dd"); 


来源:https://stackoverflow.com/questions/22199066/convert-this-kind-of-date-format-tue-mar-04-2014-000000-gmt0530-sri-lanka-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!