import android.widget.DatePicker;
import android.widget.TimePicker;
-import java.util.Date;
-import java.util.GregorianCalendar;
+import java.util.*;
+import java.util.Calendar;
public class AddAlarmActivity extends ListActivity {
public static final String EXTRA_EVENT = "event";
final DatePicker datePicker = (DatePicker) findViewById(R.id.datePicker);
final TimePicker timePicker = (TimePicker) findViewById(R.id.timePicker);
Date d=new Date(Math.max(event.dtstart,GregorianCalendar.getInstance().getTimeInMillis()));
- datePicker.init(d.getYear()+1900,d.getMonth(),d.getDay(),new DatePicker.OnDateChangedListener() {
+ GregorianCalendar gc=new GregorianCalendar();
+ gc.setTime(d);
+ datePicker.init(gc.get(Calendar.YEAR),gc.get(Calendar.MONTH),gc.get(Calendar.DAY_OF_MONTH),new DatePicker.OnDateChangedListener() {
@Override
public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
}
});
- timePicker.setCurrentHour(d.getHours());
- timePicker.setCurrentMinute(d.getMinutes());
+ timePicker.setCurrentHour(gc.get(Calendar.HOUR_OF_DAY));
+ timePicker.setCurrentMinute(gc.get(Calendar.MINUTE));
}