Code example for Calendar

Methods: getTimeInMillis, set

0
   
  private void updateLabel() { 
    dateAndTimeLabel
      .setText(DateUtils
                 .formatDateTime(this,
                                 dateAndTime.getTimeInMillis(),
                                 DateUtils.FORMAT_SHOW_DATE|DateUtils.FORMAT_SHOW_TIME));
  } 
   
  DatePickerDialog.OnDateSetListener d=new DatePickerDialog.OnDateSetListener() {
    public void onDateSet(DatePicker view, int year, int monthOfYear, 
                          int dayOfMonth) { 
      dateAndTime.set(Calendar.YEAR, year); 
      dateAndTime.set(Calendar.MONTH, monthOfYear); 
      dateAndTime.set(Calendar.DAY_OF_MONTH, dayOfMonth); 
      updateLabel(); 
    } 
  }; 
   
  TimePickerDialog.OnTimeSetListener t=new TimePickerDialog.OnTimeSetListener() {
    public void onTimeSet(TimePicker view, int hourOfDay, 
                          int minute) { 
      dateAndTime.set(Calendar.HOUR_OF_DAY, hourOfDay); 
      dateAndTime.set(Calendar.MINUTE, minute); 
      updateLabel(); 
    } 
  };   
}