Buggy code:
public class AddTaskActivity extends Activity { private EditText taskNameEditText ; private Spinner prioritySpinner ; private Spinner listSpinner ; private TextView dateView ; private TextView timeView ; private Button addButton ; private Button cancelButton ; private Time dueDate ; private DatePickerDialog datePicker ; private TimePickerDialog timePicker ; private AlertDialog unsavedChangesDialog ; private AlertDialog removeDialog ; private STApp app ; private boolean hasDate = false ; private boolean hasTime = false ; @ Override protected void onCreate ( Bundle savedInstanceState ) { } protected void addTask ( ) { } protected void cancel ( ) { } protected void setDate ( int year , int month , int day ) { } protected void setTime ( int hour , int min ) { } private void setUpViews ( ) { dueDate = new Time ( ) ; dueDate . setToNow ( ) ; <START_BUG> long millis = dueDate . toMillis ( false ) ; <END_BUG> dueDate . set ( ( millis - ( millis % 1800000 ) ) ) ; taskNameEditText = ( ( EditText ) ( findViewById ( task_name ) ) ) ; prioritySpinner = ( ( Spinner ) ( findViewById ( priority ) ) ) ; prioritySpinner . setSelection ( 3 ) ; listSpinner = ( ( Spinner ) ( findViewById ( parent_list ) ) ) ; dateView = ( ( TextView ) ( findViewById ( due_date ) ) ) ; timeView = ( ( TextView ) ( findViewById ( due_time ) ) ) ; addButton = ( ( Button ) ( findViewById ( add_button2 ) ) ) ; cancelButton = ( ( Button ) ( findViewById ( cancel_button ) ) ) ; ArrayAdapter < List > adapter = new ArrayAdapter < List > ( this , layout . simple_spinner_item , app . getLists ( ) ) ; adapter . setDropDownViewResource ( simple_spinner_dropdown_item ) ; listSpinner . setAdapter ( adapter ) ; listSpinner . setSelection ( app . getCurrentListIndex ( ) ) ; dateView . setOnClickListener ( new View . OnClickListener ( ) { public void onClick ( View v ) { datePicker = new DatePickerDialog ( AddTaskActivity . this , style . Theme_Dialog , new DatePickerDialog . OnDateSetListener ( ) { public void onDateSet ( DatePicker view , int year , int month , int day ) { setDate ( year , month , day ) ; } } , dueDate . year , dueDate . month , dueDate . monthDay ) ; datePicker . show ( ) ; } } ) ; dateView . setOnLongClickListener ( new View . OnLongClickListener ( ) { @ Override public boolean onLongClick ( View v ) { removeDialog = new AlertDialog . Builder ( AddTaskActivity . this ) . setTitle ( remove_date_title ) . setMessage ( remove_date_message ) . setPositiveButton ( cancel , new AlertDialog . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int which ) { removeDialog . cancel ( ) ; } } ) . setNegativeButton ( remove , new AlertDialog . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int which ) { hasDate = false ; hasTime = false ; removeDialog . dismiss ( ) ; } } ) . create ( ) ; removeDialog . show ( ) ; return true ; } } ) ; timeView . setOnClickListener ( new View . OnClickListener ( ) { public void onClick ( View v ) { if ( ! ( hasDate ) ) { return ; } timePicker = new TimePickerDialog ( AddTaskActivity . this , style . Theme_Dialog , new TimePickerDialog . OnTimeSetListener ( ) { public void onTimeSet ( TimePicker view , int hourOfDay , int minute ) { setTime ( hourOfDay , minute ) ; } } , dueDate . hour , dueDate . minute , true ) ; timePicker . show ( ) ; } } ) ; timeView . setOnLongClickListener ( new View . OnLongClickListener ( ) { @ Override public boolean onLongClick ( View v ) { removeDialog = new AlertDialog . Builder ( AddTaskActivity . this ) . setTitle ( remove_time_title ) . setMessage ( remove_time_message ) . setPositiveButton ( cancel , new AlertDialog . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int which ) { removeDialog . cancel ( ) ; } } ) . setNegativeButton ( remove , new AlertDialog . OnClickListener ( ) { public void onClick ( DialogInterface dialog , int which ) { hasTime = false ; removeDialog . dismiss ( ) ; } } ) . create ( ) ; removeDialog . show ( ) ; return true ; } } ) ; addButton . setOnClickListener ( new View . OnClickListener ( ) { public void onClick ( View v ) { addTask ( ) ; finish ( ) ; } } ) ; addButton . setEnabled ( false ) ; cancelButton . setOnClickListener ( new View . OnClickListener ( ) { public void onClick ( View v ) { cancel ( ) ; } } ) ; taskNameEditText . addTextChangedListener ( new TextWatcher ( ) { public void onTextChanged ( CharSequence s , int start , int before , int count ) { addButton . setEnabled ( ( ! ( taskNameEditText . getText ( ) . toString ( ) . equals ( "" ) ) ) ) ; } public void beforeTextChanged ( CharSequence s , int start , int count , int after ) { } public void afterTextChanged ( Editable s ) { } } ) ; } }

Fix:
long millis = dueDate . toMillis ( true ) ;