In a java class, i get the date as string say “renewDate” from the datepicker-input form in mm/dd/yyyy.
When i try to update in the code using joda time library
DateTime expireDate = new DateTime(renewDate);
// i get error at above line
updateOrganization.setRenewdate(expireDate.toDate());
organizationDAO.update(updateOrganization);
but if i format the date in the form i.e, from mm/dd/yyyy to yyyy-mm-dd and send it to the java class its working fine.
How can i format the date from mm/dd/yy to yyyy-mm-dd at Java class. Input is Stringformat.
The list of valid formats for the constructor you are using are detailed in the javadoc of ISODateTimeFormat, which does not include “mm/dd/yyyy”:
You can parse a different format with a DateTimeFormatter (note MM in upper case for month):