]> iEval git - unical.git/commitdiff
Date and time pickers are now set correctly
authorPetru <l3asketballplayer@yahoo.com>
Thu, 22 Aug 2013 10:56:11 +0000 (13:56 +0300)
committerPetru <l3asketballplayer@yahoo.com>
Thu, 22 Aug 2013 10:56:11 +0000 (13:56 +0300)
src/ro/ieval/unical/AddAlarmActivity.java

index 851edaee11b73239cf671a5b569a9be205748123..527250e6723dde2d5fb3d1d4332a2d8096da5d88 100644 (file)
@@ -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));
 
     }
 
This page took 0.017716 seconds and 4 git commands to generate.