Android examples for android.widget:Button
update button text to Time Date
import android.widget.Button; import java.util.Calendar; import java.util.GregorianCalendar; public class Main{ public static void updateTimeDate(Button date, Button time, GregorianCalendar gc) { if (date != null) { int mYear = gc.get(Calendar.YEAR); int mMonth = gc.get(Calendar.MONTH); int mDay = gc.get(Calendar.DAY_OF_MONTH); date.setText("" + mDay + "-" + (mMonth + 1) + "-" + mYear); }/* ww w. j av a2 s .c o m*/ if (time != null) { int mHour = gc.get(Calendar.HOUR_OF_DAY); int mMinute = gc.get(Calendar.MINUTE); time.setText("" + StringUtils.pad(mHour) + ":" + StringUtils.pad(mMinute)); } } }