I am trying to update google calendar event start and end datetime in spring class.But i am getting DateFormat exception.I am able to get particular event and display in modal popup.I am using kendo directives datepicker.Now if the user edits the start and end date it is getting changed in this format
String start=2/21/2018 8:00 PM
String end:2/22/2018 9:00 PM
Now i am trying to set these dates for google event start and endDate like this in my class
ServiceImpl.java
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
try {
Date d = sdf.parse(start);//2/21/2018 8:00 PM
Date end = sdf.parse(end);//2/22/2018 9:00 PM
event.setStart(new EventDateTime().setDateTime(new DateTime(d)));
event.setEnd(new EventDateTime().setDateTime(new DateTime(end)));
// Update the event
Event updatedEvent = service.events().patch("primary", googleEventDto.getEventId(), event).execute();
} catch (ParseException e)
{
// execution will come here if the String that is given
// does not match the expected format.
e.printStackTrace();
}
But i am getting exception Unparseable date 2/21/2018 8:00 PM.But if set directly like this
event.setStart(new EventDateTime().setDateTime(new DateTime("2018-02-28T07:00:00.000+05:30")));
event.setStart(new EventDateTime().setDateTime(new DateTime("2018-02-28T09:00:00.000+05:30")));
It is working perfectly.Can anyone tell how can i parse date 2/21/2018 8:00 into this format 2018-02-21T08:00:00.000+05:30?