Here you can find the source of initDate(TextView view,int days)
public static void initDate(TextView view,int days)
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.regex.Matcher; import java.util.regex.Pattern; import android.widget.TextView; public class Main{ public static void initDate(TextView view,int days) { //from w w w . j a v a 2 s .c om Calendar c = Calendar.getInstance(); c.add(Calendar.DAY_OF_MONTH, days); int mYear = c.get(Calendar.YEAR); int mMonth = c.get(Calendar.MONTH); int mDay = c.get(Calendar.DAY_OF_MONTH); String dateStr = new StringBuilder().append(mYear).append("-").append( format(mMonth + 1)).append("-").append(format(mDay)).toString(); view.setText(dateStr+" "+getWeek(dateStr)); } private static String format(int x) { String s = "" + x; if (s.length() == 1) s = "0" + s; return s; } public static String getWeek(String date) { Date dat = null; SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); try { dat = simpleDateFormat.parse(date); } catch (ParseException e) { e.printStackTrace(); } return getChineseWeek(dat); } }