String to Date and Time object conversion – Android

Converting String object to Date object is common and trivial problem in Android App. The simple solution convert the string to date format then we can make any format

I performed the date conversion below:

String myDate ="28-11-2013"
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");  
Date mydate = sdf.parse(currentRow.getBoardingDate());

To do the opposite, to convert the date back to a string, you can use the following code:

sdf = new SimpleDateFormat("MMM, dd yyyy");

Here is the SimpleDateFormat Documentation for more details