Android examples for java.util:Date Format
get Current Date by format with exception handler
import android.text.TextUtils; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main{ public static String getCurrentDate(String format) { String curDateTime = null; try {//from w w w . j a va 2s .c o m SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat( format); Calendar c = new GregorianCalendar(); curDateTime = mSimpleDateFormat.format(c.getTime()); } catch (Exception e) { e.printStackTrace(); } return curDateTime; } }