Skip to content

Instantly share code, notes, and snippets.

@devrath
Created November 27, 2014 11:51
Show Gist options
  • Select an option

  • Save devrath/e1c01fc01d0adfbb7858 to your computer and use it in GitHub Desktop.

Select an option

Save devrath/e1c01fc01d0adfbb7858 to your computer and use it in GitHub Desktop.
Convert one date format to another
String startDateString = edtTxtDateId.getText().toString();
String newDateString = null;
DateFormat df = new SimpleDateFormat("yyyy/mm/dd",Locale.ENGLISH);
DateFormat sdf = new SimpleDateFormat("mm/dd/yyyy",Locale.ENGLISH);
Date startDate;
try {
startDate = sdf.parse(startDateString);
newDateString = df.format(startDate);
System.out.println(newDateString);
} catch (ParseException e) {
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment