Android examples for java.util:Day
get Day Number in int value
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import android.util.Log; public class Main { public static int MIN_YEAR = 1970; public static int getDayNum(int index) { int year = MIN_YEAR + index / 12; int month = index % 12; SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); Calendar date = new GregorianCalendar(year, month, 1); int daynum = date.getActualMaximum(Calendar.DAY_OF_MONTH); SimpleDateFormat df1 = new SimpleDateFormat("EEEE"); Date d = date.getTime();//from w w w . jav a 2 s . c o m Log.i("Main", df.format(d)); int day_of_week = date.get(Calendar.DAY_OF_WEEK); Date dt = date.getTime(); Log.i("Main", df.format(dt) + " " + df1.format(dt) + " DAY_OF_MONTH??" + day_of_week + " date.getday:" + dt.getDay()); return daynum; } }