From: Petru Date: Thu, 22 Aug 2013 10:56:11 +0000 (+0300) Subject: Date and time pickers are now set correctly X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=14986c26c23e28875d544ca258fc3142d84b3d33;p=unical.git Date and time pickers are now set correctly --- diff --git a/src/ro/ieval/unical/AddAlarmActivity.java b/src/ro/ieval/unical/AddAlarmActivity.java index 851edae..527250e 100644 --- a/src/ro/ieval/unical/AddAlarmActivity.java +++ b/src/ro/ieval/unical/AddAlarmActivity.java @@ -12,8 +12,8 @@ import android.view.MenuItem; 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"; @@ -36,13 +36,15 @@ public class AddAlarmActivity extends ListActivity { 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)); }