Question: I am developing a taskmanager on Android 2.1.
I want to reset date and time on clicking the reset button to current date and time.
Help me with the code..

```
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final EditText next = (EditText) findViewById(R.id.editText1);
final Button sub = (Button) findViewById(R.id.button1);
final Button res = (Button) findViewById(R.id.button2);
final DatePicker dp= (DatePicker) findViewById(R.id.datePicker1);
final TimePicker tp = (TimePicker) findViewById(R.id.timePicker1);

res.setOnClickListener(new View.OnClickListener() {     
 public void onClick(final View view) {                  
     next.setText("");
     dp.refreshDrawableState();
        }       
    });    
}}

```

Answer: 
```
//get current time
Time now = new Time();
now.setToNow();

//update the TimePicker
tp.setHour(now.hour);
tp.setMinute(now.minute);

//update the DatePicker
dp.updateDate(now.year, now.month, now.monthDay);

```
`Time` is now deprecated. Use `Calendar` instead:

```
Calendar calendar = Calendar.getInstance();

tp.setHour(calendar.get(Calendar.HOUR_OF_DAY));
tp.setMinute(calendar.get(Calendar.MINUTE));      

dp.updateDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));

```