Android examples for java.util:Day
get Day from date string
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 int getDay(String strDate, String format) { int day = 0; try {/*from w w w . ja va2 s . c o m*/ Calendar c = new GregorianCalendar(); SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat( format); c.setTime(mSimpleDateFormat.parse(strDate)); day = c.get(Calendar.DAY_OF_MONTH); } catch (Exception e) { e.printStackTrace(); } return day; } }