Java 类android.app.DatePickerDialog 实例源码

项目:Udhari    文件:DatePickerFragment.java   
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the current date as the default date in the picker
    final Calendar c = Calendar.getInstance();
    int year = c.get(Calendar.YEAR);
    int month = c.get(Calendar.MONTH);
    int day = c.get(Calendar.DAY_OF_MONTH);


    // Create a new instance of DatePickerDialog and return it
    DatePickerDialog datePickerDialog = new DatePickerDialog(getActivity(),
            (DatePickerDialog.OnDateSetListener) getActivity(), year, month, day);
    c.set(Calendar.HOUR_OF_DAY, 12);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    datePickerDialog.getDatePicker().setMinDate(c.getTimeInMillis());
    return datePickerDialog;
}
项目:12306_Android    文件:DatePickerFragment.java   
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    chooseDate = (TextView) getActivity().findViewById(R.id.choose_date);
    chooseDate2 = (TextView) getActivity().findViewById(R.id.choose_date2);

    String date = chooseDate.getText().toString();
    int year = Integer.parseInt(date.split("-")[0]);
    int month = Integer.parseInt(date.split("-")[1]);
    int day = Integer.parseInt(date.split("-")[2]);

    DatePickerDialog dialog = new DatePickerDialog(getContext(), this, year, month - 1, day);
    dialog.getDatePicker().setMinDate(System.currentTimeMillis() - 1000);
    dialog.getDatePicker().setMaxDate(System.currentTimeMillis() + (long) 29 * 24 * 60 * 60 * 1000);
    dialog.setTitle(null);
    return dialog;
}
项目:MADBike    文件:RegisterActivity.java   
@OnClick(R.id.dateButton)
public void onDatePressed() {
    dateFormatter = new SimpleDateFormat("dd-MM-yyyy", Locale.ENGLISH);
    Calendar newCalendar = Calendar.getInstance();
    fromDatePickerDialog = new DatePickerDialog(RegisterActivity.this, new DatePickerDialog.OnDateSetListener() {

        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            Calendar c = Calendar.getInstance();
            c.set(Calendar.YEAR, year);
            c.set(Calendar.MONTH, monthOfYear);
            c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            Calendar currentTime = Calendar.getInstance();
            if ((currentTime.getTimeInMillis() - FOURTEEN_YEARS) >= c.getTimeInMillis()) {
                dateButton.setText(dayOfMonth + "-" + (monthOfYear + 1) + "-" + year);
            } else {
                dialogManager.showPositiveDialog(R.string.age_title, R.string.age_message, android.R.string.ok);
            }
        }

    }
            , newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.MONTH), newCalendar.get(Calendar.DAY_OF_MONTH));
    fromDatePickerDialog.show();
}
项目:FitnessHabits    文件:MainActivity.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.datepicker) {
        Calendar currentDate = Calendar.getInstance();
        if (currentDate != null) {
            DatePickerDialog datePickerDialog = new DatePickerDialog(this, this, currentDate.get(Calendar.YEAR), currentDate.get(Calendar.MONTH), currentDate.get(Calendar.DAY_OF_MONTH));
            datePickerDialog.show();
            return true;
        }
    } else if (item.getItemId() == R.id.param) {
        startActivity(new Intent(this, ParameterActivity.class));
        return true;
    } else if (item.getItemId() == R.id.objectif) {
        // activité temporaire, pour expérimenter. à enlever seulement à la fin de la journée
        Intent intent = new Intent(this, TestActivity.class);
        this.startActivity(intent);
        return true;
    }
    return super.onOptionsItemSelected(item);
}
项目:MyCalendar    文件:DatePickerDiaLogFragment.java   
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Bundle bundle = this.getArguments();

    if (bundle == null) {
        return new DatePickerDialog(getActivity(), this, 0, 0, 0);
    }

    mIdView = bundle.getInt(DATE_PICKER_DIALOG_ID_VIEW);
    Long timeInMillis = bundle.getLong(DATE_PICKER_DIALOG_TIME_IN_MILLIS);

    cal.setTimeInMillis(timeInMillis);
    int year = cal.get(Calendar.YEAR);
    int month = cal.get(Calendar.MONTH);
    int day = cal.get(Calendar.DAY_OF_MONTH);

    return new DatePickerDialog(getActivity(), this, year, month, day);
}
项目:Sanxing    文件:OperateTimeLeftActivityBase.java   
@OnClick(R.id.time_left_from_date_content)
void timeLeftStartDateOnClickBehavior() {
    DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            startCalendar.set(Calendar.YEAR, year);
            startCalendar.set(Calendar.MONTH, monthOfYear);
            startCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            DateFormat sdf = android.text.format.DateFormat.getDateFormat(getBaseContext());
            startDateContent.setText(sdf.format(startCalendar.getTime()));
            setDate1 = true;
        }
    };
    new DatePickerDialog(this, date,
            startCalendar.get(Calendar.YEAR),
            startCalendar.get(Calendar.MONTH),
            startCalendar.get(Calendar.DAY_OF_MONTH)).show();
}
项目:Sanxing    文件:OperateTimeLeftActivityBase.java   
@OnClick(R.id.time_left_due_date_content)
void timeLeftDueDateOnClickBehavior() {
    DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            dueCalendar.set(Calendar.YEAR, year);
            dueCalendar.set(Calendar.MONTH, monthOfYear);
            dueCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            DateFormat sdf = android.text.format.DateFormat.getDateFormat(getBaseContext());
            dueDateContent.setText(sdf.format(dueCalendar.getTime()));
            setDate2 = true;
        }
    };
    new DatePickerDialog(this, date,
            dueCalendar.get(Calendar.YEAR),
            dueCalendar.get(Calendar.MONTH),
            dueCalendar.get(Calendar.DAY_OF_MONTH)).show();
}
项目:Sanxing    文件:OperateTaskActivityBase.java   
@OnClick(R.id.task_due_date_content)
void taskDueDateOnClickBehavior() {
    DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            dueCalendar.set(Calendar.YEAR, year);
            dueCalendar.set(Calendar.MONTH, monthOfYear);
            dueCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            DateFormat sdf = android.text.format.DateFormat.getDateFormat(getBaseContext());
            dueDateContent.setText(sdf.format(dueCalendar.getTime()));
            setDate = true;
        }
    };
    new DatePickerDialog(this, date,
            dueCalendar.get(Calendar.YEAR),
            dueCalendar.get(Calendar.MONTH),
            dueCalendar.get(Calendar.DAY_OF_MONTH)).show();
}
项目:Sanxing    文件:HabitCalendarFragment.java   
@OnClick(R.id.habit_calendar_year_month)
void habitCalendarYearMonthOnClickBehavior() {
    DatePickerDialog.OnDateSetListener dateListener = new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            selectedCalendar.set(Calendar.YEAR, year);
            selectedCalendar.set(Calendar.MONTH, monthOfYear);
            selectedCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            habitCalendarView.setCurrentDate(selectedCalendar.getTime());
            updateHabitCalendarYearMonth();
            updateHabitDetails(selectedCalendar.getTime());
        }
    };
    new DatePickerDialog(this.getContext(), dateListener,
            selectedCalendar.get(Calendar.YEAR),
            selectedCalendar.get(Calendar.MONTH),
            selectedCalendar.get(Calendar.DAY_OF_MONTH)).show();
}
项目:Sanxing    文件:TaskCalendarFragment.java   
@OnClick(R.id.task_calendar_year_month)
void taskCalendarYearMonthOnClickBehavior() {
    DatePickerDialog.OnDateSetListener dateListener = new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            selectedCalendar.set(Calendar.YEAR, year);
            selectedCalendar.set(Calendar.MONTH, monthOfYear);
            selectedCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            taskCalendarView.setCurrentDate(selectedCalendar.getTime());
            updateTaskCalendarYearMonth();
            updateTaskDetails(selectedCalendar.getTime());
        }
    };
    new DatePickerDialog(this.getContext(), dateListener,
            selectedCalendar.get(Calendar.YEAR),
            selectedCalendar.get(Calendar.MONTH),
            selectedCalendar.get(Calendar.DAY_OF_MONTH)).show();
}
项目:quickhybrid-android    文件:UIApi.java   
/**
 * 弹出日期选择对话框
 * <p>
 * 参数:
 * title: 标题
 * datetime: 指定日期 yyyy-MM-dd
 * 返回:
 * date: 格式:yyyy-MM-dd
 */
public static void pickDate(final IQuickFragment webLoader, WebView wv, JSONObject param, final Callback callback) {
    final String title = param.optString("title");
    String date = param.optString("datetime");
    final Calendar calendar = Calendar.getInstance();
    if (!TextUtils.isEmpty(date)) {
        calendar.setTime(DateUtil.convertString2Date(date, "yyyy-MM-dd"));
    }
    wv.post(new Runnable() {
        public void run() {
            DialogUtil.pickDate(webLoader.getPageControl().getActivity(), title, calendar, new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                    calendar.set(Calendar.YEAR, year);
                    calendar.set(Calendar.MONTH, monthOfYear);
                    calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                    String chooseDate = DateUtil.convertDate(calendar.getTime(), "yyyy-MM-dd");
                    Map<String, Object> map = new HashMap<>();
                    map.put("date", chooseDate);
                    callback.applySuccess(map);
                }
            });
        }
    });
}
项目:quickhybrid-android    文件:UIApi.java   
/**
 * 弹出年月选择对话框
 * <p>
 * 参数:
 * title: 标题
 * datetime: 指定日期 yyyy-MM
 * 返回:
 * month: 格式:yyyy-MM
 */
public static void pickMonth(final IQuickFragment webLoader, WebView wv, JSONObject param, final Callback callback) {
    String title = param.optString("title");
    String date = param.optString("datetime");
    final Calendar calendar = Calendar.getInstance();
    if (!TextUtils.isEmpty(date)) {
        calendar.setTime(DateUtil.convertString2Date(date, "yyyy-MM"));
    }
    DialogUtil.pickMonth(webLoader.getPageControl().getActivity(), title, calendar, new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            calendar.set(Calendar.YEAR, year);
            calendar.set(Calendar.MONTH, monthOfYear);
            calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            String chooseDate = DateUtil.convertDate(calendar.getTime(), "yyyy-MM");
            Map<String, Object> map = new HashMap<>();
            map.put("month", chooseDate);
            callback.applySuccess(map);
        }
    });
}
项目:LocaleChanger    文件:SampleActivity.java   
@OnClick(R.id.showDatePicker)
void onShowDatePickerClick() {
    Calendar now = Calendar.getInstance();

    DatePickerDialog dialog = new DatePickerDialog(
            SampleActivity.this,
            new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                }
            },
            now.get(Calendar.YEAR),
            now.get(Calendar.MONTH),
            now.get(Calendar.DAY_OF_MONTH));

    dialog.show();
}
项目:LocaleChanger    文件:SampleFragment.java   
@OnClick(R.id.showDatePicker)
void onShowDatePickerClick() {
    Calendar now = Calendar.getInstance();

    DatePickerDialog dialog = new DatePickerDialog(
            getActivity(),
            new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                }
            },
            now.get(Calendar.YEAR),
            now.get(Calendar.MONTH),
            now.get(Calendar.DAY_OF_MONTH));

    dialog.show();
}
项目:RNLearn_Project1    文件:DatePickerDialogTestCase.java   
public void testCallback() throws Throwable {
  final WritableMap options = new WritableNativeMap();
  options.putDouble("date", getDateInMillis(2020, 5, 6));

  final DialogFragment datePickerFragment = showDialog(options);

  runTestOnUiThread(
      new Runnable() {
        @Override
        public void run() {
          ((DatePickerDialog) datePickerFragment.getDialog())
              .getButton(DialogInterface.BUTTON_POSITIVE).performClick();
        }
      });

  getInstrumentation().waitForIdleSync();
  waitForBridgeAndUIIdle();

  assertEquals(0, mRecordingModule.getErrors());
  assertEquals(1, mRecordingModule.getDates().size());
  assertEquals(2020, (int) mRecordingModule.getDates().get(0)[0]);
  assertEquals(5, (int) mRecordingModule.getDates().get(0)[1]);
  assertEquals(6, (int) mRecordingModule.getDates().get(0)[2]);
}
项目:KTools    文件:KDialogActivity.java   
@OnClick(R.id.btn_choose_date_dialog)
public void onBtnChooseDateDialogClicked() {
    final Calendar calendar = Calendar.getInstance();
    DatePickerDialog dialog = new DatePickerDialog(
            this,
            new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
                    calendar.set(Calendar.YEAR, year);
                    calendar.set(Calendar.MONTH, month);
                    calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                    String date = DateFormat.getDateInstance(DateFormat.FULL).format(calendar.getTime());
                    ToastUtils.showShortToast(date);
                }
            }, calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
    dialog.show();
}
项目:XDaysClean    文件:DatePickerFragment.java   
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the current date as the default date in the picker
    final Calendar c = Calendar.getInstance();
    int year = c.get(Calendar.YEAR);
    int month = c.get(Calendar.MONTH);
    int day = c.get(Calendar.DAY_OF_MONTH);


    // Create a new instance of DatePickerDialog and return it
    DatePickerDialog dialog = new DatePickerDialog(getActivity(), this, year, month, day);
    dialog.getDatePicker().setMaxDate(new Date().getTime());

    return dialog;
}
项目:ChenYan    文件:MyInfoActivity.java   
private void showDateDialog(final TextView textView) {
    Calendar calendar = Calendar.getInstance();
    int year = calendar.get(Calendar.YEAR);
    int month = calendar.get(Calendar.MONTH);
    int day = calendar.get(Calendar.DAY_OF_MONTH);
    DatePickerDialog dialog =
            new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker datePicker, int i, int i1, int i2) {
                    //      birthday = new Date(i,i1,i2);
                    Date date = new Date(i - 1900, i1, i2);

                    textView.setText(formatDate(date));
                }
            }, year, month, day);
    dialog.show();

}
项目:CouponsTracker    文件:CouponFragment.java   
private void showDatePickerDialog(Calendar calendar) {
    DebugLog.logMethod();
    if (calendar == null) {
        DebugLog.logMessage("Null calendar");
        return;
    }

    DebugLog.logMessage("Calendar time: " + calendar.getTime().toString());
    datePickerDialog = new DatePickerDialog(
            getContext(),
            R.style.PickerTheme,
            CouponFragment.this,
            calendar.get(Calendar.YEAR),
            calendar.get(Calendar.MONTH),
            calendar.get(Calendar.DAY_OF_MONTH)
    );
    datePickerDialog.getDatePicker().setMinDate(calendar.getTimeInMillis());
    datePickerDialog.setTitle(getString(R.string.title_date_picker));
    datePickerDialog.show();
}
项目:dhbw-timetable-android    文件:WeekFragment.java   
private void pickWeek(final View view, final Activity activity) {
    if (!TimetableManager.getInstance().isRunning()) {
        DatePickerDialog.OnDateSetListener handler = (dpView, year, month, day) -> {
            weekToDisplay.set(Calendar.YEAR, year);
            weekToDisplay.set(Calendar.MONTH, month);
            weekToDisplay.set(Calendar.DAY_OF_MONTH, day);
            Log.i("DATE", "Picked date: " + day + "." + month + "." + year);
            displayWeek(view, activity, false);
        };

        DatePickerDialog dpd = new DatePickerDialog(getContext(), handler,
                weekToDisplay.get(Calendar.YEAR),
                weekToDisplay.get(Calendar.MONTH),
                weekToDisplay.get(Calendar.DAY_OF_MONTH));
        dpd.show();
    } else {
        Toast.makeText(activity, "I'm currently busy, sorry!", Toast.LENGTH_SHORT).show();
    }
}
项目:liveomvp    文件:DatePickerFragment.java   
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    int year = getCalendar().get(Calendar.YEAR);
    int month = getCalendar().get(Calendar.MONTH);
    int day = getCalendar().get(Calendar.DAY_OF_MONTH);

    DatePickerDialog datePickerDialog = new DatePickerDialog(getActivity(), this,
            year, month, day);

    if (disableFutureDate) {
        datePickerDialog.getDatePicker().setMaxDate(System.currentTimeMillis());
    }

    return datePickerDialog;
}
项目:Veggietizer    文件:DatePickerFragment.java   
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Uses the current date as the default date in the picker
    Calendar c = Calendar.getInstance();
    int year = c.get(Calendar.YEAR);
    int month = c.get(Calendar.MONTH);
    int day = c.get(Calendar.DAY_OF_MONTH);
    DatePickerDialog dialog = new DatePickerDialog(getActivity(), this, year, month, day);
    DatePicker datePicker = dialog.getDatePicker();

    datePicker.setCalendarViewShown(false);
    numOfCalls = 0;

    return dialog;
}
项目:CIA    文件:DatePickerFragment.java   
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Calendar calendar = Calendar.getInstance();
    int year = calendar.get(Calendar.YEAR);
    int month = calendar.get(Calendar.MONTH);
    int day = calendar.get(Calendar.DAY_OF_MONTH);

    DatePickerDialog.OnDateSetListener listener = (DatePickerDialog.OnDateSetListener) getActivity();

    // Create a new instance of TimePickerDialog and return it
    return new DatePickerDialog(getActivity(), listener, year, month, day);
}
项目:GitHub    文件:DynamicSettersActivity.java   
@OnClick(R.id.button_min_date)
void onMinClicked() {
    showDatePickerDialog(this, widget.getMinimumDate(), new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            widget.state().edit()
                    .setMinimumDate(CalendarDay.from(year, monthOfYear, dayOfMonth))
                    .commit();
        }
    });
}
项目:Bee-Analyzer    文件:DateField.java   
@Override
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.editText:
            new DatePickerDialog(ctx, this, Start
                    .get(Calendar.YEAR), Start.get(Calendar.MONTH),
                    Start.get(Calendar.DAY_OF_MONTH)).show();
            break;
        case R.id.button:
            String dateText = String.valueOf(editText.getText());
            if(dateText == null || dateText.isEmpty())
                new DatePickerDialog(ctx, this, Start
                        .get(Calendar.YEAR), Start.get(Calendar.MONTH),
                        Start.get(Calendar.DAY_OF_MONTH)).show();
            if(!(dateText == null || dateText.isEmpty())) {
                markerTimer.cancel();
                TelephonyManager tm = (TelephonyManager) ctx.getSystemService(TELEPHONY_SERVICE);
                String imei = tm.getDeviceId();
                SimpleDateFormat df = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
                String mindate = df.format(Start.getTime());
                String maxdate = df.format(Stop.getTime());
                new DBTransaction.AsyncGetOwnRoutes(this.mapIn).execute(imei, mindate, maxdate);
            }
            break;
    }


}
项目:GitHub    文件:DynamicSettersActivity.java   
public static void showDatePickerDialog(Context context, CalendarDay day,
                                        DatePickerDialog.OnDateSetListener callback) {
    if (day == null) {
        day = CalendarDay.today();
    }
    DatePickerDialog dialog = new DatePickerDialog(
            context, 0, callback, day.getYear(), day.getMonth(), day.getDay()
    );
    dialog.show();
}
项目:hackmelock-android    文件:DatePickerFragment.java   
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Use the current date as the default date in the picker
    final Calendar c = Calendar.getInstance();
    int year = c.get(Calendar.YEAR);
    int month = c.get(Calendar.MONTH);
    int day = c.get(Calendar.DAY_OF_MONTH);

    // Create a new instance of DatePickerDialog and return it
    return new DatePickerDialog(getActivity(), this, year, month, day);
}
项目:wirtualnaApteczka    文件:DatePickerFragment.java   
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Calendar calendar = Calendar.getInstance();

    if (medicineForUpdate.getDueDate() != null) {
        calendar.setTime(medicineForUpdate.getDueDate());
    }

    int year = calendar.get(Calendar.YEAR);
    int month = calendar.get(Calendar.MONTH);
    int day = calendar.get(Calendar.DAY_OF_MONTH);

    return new DatePickerDialog(getActivity(), new MedicineDueDateSetListener(medicineForUpdate, getActivity()), year, month, day);
}
项目:permitlog-android    文件:DriveDateFragment.java   
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    //Get the default date from the arguments:
    int year = getArguments().getInt("year");
    int month = getArguments().getInt("month");
    int day = getArguments().getInt("day");
    //Return a DatePickerDialog which has a default date of today:
    return new DatePickerDialog(getActivity(), this, year, month, day);
}
项目:leoapp-sources    文件:NewEntryDialog.java   
private void setDateTimeField(final TextView t) {
    final Calendar         newCalendar   = Calendar.getInstance();
    final SimpleDateFormat dateFormatter = new SimpleDateFormat("dd-MM-yyyy", Locale.GERMANY);
    datePickerDialog = new DatePickerDialog(getContext(), new DatePickerDialog.OnDateSetListener() {

        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            Calendar newDate = Calendar.getInstance();
            newDate.set(year, monthOfYear, dayOfMonth);
            t.setText(dateFormatter.format(newDate.getTime()));
        }
    }, newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.MONTH), newCalendar.get(Calendar.DAY_OF_MONTH));
}
项目:FamilyLibraryManager    文件:DetailsActivity.java   
/**
 * 显示时间捡取器
 */
private void showDatePickerDialog() {
    new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            showDate.set(Calendar.YEAR, year);
            showDate.set(Calendar.MONTH, monthOfYear);
            showDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            bookDateEditText.setText(DateFormat.format("yyyy-MM-dd", showDate));
        }
    }, showDate.get(Calendar.YEAR), showDate.get(Calendar.MONTH), showDate.get(Calendar.DAY_OF_MONTH)).show();
}
项目:schulcloud-mobile-android    文件:AddHomeworkFragment.java   
private void initDateButton(Calendar calendar, TextView button) {
    button.setText(mDateFormat.format(calendar.getTime()));
    button.setOnClickListener((v) ->
    {
        try {
            calendar.setTime(mDateFormat.parse(button.getText().toString()));
        } catch (ParseException e) {
            Timber.e(e, "There was an error loading the courses.");
        }
        new DatePickerDialog(getActivity(),
                (dialog, year, month, dayOfMonth) ->
                {
                    calendar.set(Calendar.YEAR, year);
                    calendar.set(Calendar.MONTH, month);
                    calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                    new TimePickerDialog(getActivity(),
                            (view, hourOfDay, minute) ->
                            {
                                calendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
                                calendar.set(Calendar.MINUTE, minute);
                                button.setText(mDateFormat.format(calendar.getTime()));
                            },
                            calendar.get(Calendar.HOUR_OF_DAY),
                            calendar.get(Calendar.MINUTE), true)
                            .show();
                },
                calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
                calendar.get(Calendar.DAY_OF_MONTH))
                .show();
    });
}
项目:FamilyLibraryManager    文件:SearchFragment.java   
/**
 * 显示时间捡取器
 */
private void showDatePickerDialog() {
    new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            showDate.set(Calendar.YEAR, year);
            showDate.set(Calendar.MONTH, monthOfYear);
            showDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
            bookDateEditText.setText(DateFormat.format("yyyy-MM-dd", showDate));
        }
    }, showDate.get(Calendar.YEAR), showDate.get(Calendar.MONTH), showDate.get(Calendar.DAY_OF_MONTH)).show();
}
项目:aftercare-app-android    文件:DCUtils.java   
/**
 * Date picker
 * @param context
 * @param from
 * @param to
 * @param listener
 */
public static void pickDate(Context context, Date set, Date from, Date to, final IDatePickerListener listener) {
    final Calendar calendar = Calendar.getInstance();
    if (set != null) {
        calendar.setTime(set);
    }

    int year = calendar.get(Calendar.YEAR);
    int month = calendar.get(Calendar.MONTH);
    int day = calendar.get(Calendar.DAY_OF_MONTH);

    DatePickerDialog datePickerDialog = new DatePickerDialog(context, new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int y, int m, int d) {
            if (listener != null) {
                calendar.set(Calendar.YEAR, y);
                calendar.set(Calendar.MONTH, m);
                calendar.set(Calendar.DAY_OF_MONTH, d);
                listener.onPickedDate(calendar.getTime());
            }
        }
    }, year, month, day);

    if (from != null) {
        datePickerDialog.getDatePicker().setMinDate(from.getTime());
    }

    if (to != null) {
        datePickerDialog.getDatePicker().setMaxDate(to.getTime());
    }

    datePickerDialog.show();
}
项目:CodeWatch    文件:ProjectDeadlineGoalFragment.java   
@OnClick(R.id.date)
public void onDateClick() {

    final Calendar calendar = Calendar.getInstance();
    calendar.setTime(new Date(deadlineDate));

    DatePickerDialog datePickerDialog =
            new DatePickerDialog(getActivity(),
                    this,
                    calendar.get(Calendar.YEAR),
                    calendar.get(Calendar.MONTH),
                    calendar.get(Calendar.DAY_OF_MONTH));
    datePickerDialog.getDatePicker().setMinDate(System.currentTimeMillis());
    datePickerDialog.show();
}
项目:FitnessHabits    文件:ParameterActivity.java   
public void showDatePickerDialog(View v) {
    final Calendar c = Calendar.getInstance();
    int year = c.get(Calendar.YEAR);
    int month = c.get(Calendar.MONTH);
    int day = c.get(Calendar.DAY_OF_MONTH);

    DatePickerDialog newFragment = new DatePickerDialog(this, this, year, month, day);
    newFragment.show();
}
项目:Phoenix-for-VK    文件:DateTimePicker.java   
private void show(){
    final Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(time);

    int year = calendar.get(Calendar.YEAR);
    int month = calendar.get(Calendar.MONTH);
    int day = calendar.get(Calendar.DAY_OF_MONTH);
    final int hours = calendar.get(Calendar.HOUR_OF_DAY);
    final int minutes = calendar.get(Calendar.MINUTE);

    Logger.d(TAG, "onTimerClick, init time: " + new Date(time));

    new DatePickerDialog(context, (view, newYear, newMonth, newDay) ->
            showTime(newYear, newMonth, newDay, hours, minutes), year, month, day).show();
}
项目:homeworkManager-android    文件:BaseActivity.java   
static void datePickerDialog(Calendar calendar, Context context, EditText dueDateEditText) {
    DatePickerDialog.OnDateSetListener date = (view, year, month, dayOfMonth) -> {
        calendar.set(Calendar.YEAR, year);
        calendar.set(Calendar.MONTH, month);
        calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
        updateLabel(dueDateEditText, context, calendar);
    };
    new DatePickerDialog(context, date, calendar
            .get(Calendar.YEAR), calendar.get(Calendar.MONTH),
            calendar.get(Calendar.DAY_OF_MONTH)).show();
}
项目:calendarview2    文件:DynamicSettersActivity.java   
@OnClick(R.id.button_selected_date)
void onSelectedClicked() {
    showDatePickerDialog(this, widget.getSelectedDate(), new DatePickerDialog.OnDateSetListener() {
        @Override
        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            widget.setSelectedDate(CalendarDay.from(year, monthOfYear, dayOfMonth));
        }
    });
}
项目:TestChat    文件:EditUserInfoDetailActivity.java   
private void openDatePicker() {
        CustomDatePickerDialog dialog = new CustomDatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
                @Override
                public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
                        currentYear = year;
                        currentMonth = month;
                        currentDay = dayOfMonth;
                        updateDateChanged();
                }
        }, currentYear, currentMonth, currentDay);
        dialog.show();
}