List of usage examples for android.widget DatePicker getDayOfMonth
public int getDayOfMonth()
From source file:com.cavega.DatePickerDialogSample.DatePickerDialogFragment.java
@TargetApi(11) @Override/*from w w w.j ava 2 s . c o m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { // Jelly Bean introduced a bug in DatePickerDialog (and possibly // TimePickerDialog as well), and one of the possible solutions is // to postpone the creation of both the listener and the BUTTON_* . // // Passing a null here won't harm because DatePickerDialog checks for a null // whenever it reads the listener that was passed here. >>> This seems to be // true down to 1.5 / API 3, up to 4.1.1 / API 16. <<< No worries. For now. // // See my own question and answer, and details I included for the issue: // // http://stackoverflow.com/a/11493752/489607 // http://code.google.com/p/android/issues/detail?id=34833 // // Of course, suggestions welcome. final DatePickerDialog picker = new DatePickerDialog(getActivity(), getConstructorListener(), year, month, day); if (hasJellyBeanAndAbove()) { picker.setButton(DialogInterface.BUTTON_POSITIVE, getActivity().getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { DatePicker dp = picker.getDatePicker(); mListener.onDateSet(dp, dp.getYear(), dp.getMonth(), dp.getDayOfMonth()); } }); picker.setButton(DialogInterface.BUTTON_NEGATIVE, getActivity().getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); } return picker; }
From source file:com.propelforwardmedia.app.DatePickerDialogFragment.java
@TargetApi(11) @Override//from w w w . j av a 2 s. com public Dialog onCreateDialog(Bundle savedInstanceState) { int year = mCalendar.get(Calendar.YEAR); int month = mCalendar.get(Calendar.MONTH); int day = mCalendar.get(Calendar.DAY_OF_MONTH); // Jelly Bean introduced a bug in DatePickerDialog (and possibly // TimePickerDialog as well), and one of the possible solutions is // to postpone the creation of both the listener and the BUTTON_* . // // Passing a null here won't harm because DatePickerDialog checks for a null // whenever it reads the listener that was passed here. >>> This seems to be // true down to 1.5 / API 3, up to 4.1.1 / API 16. <<< No worries. For now. // // See my own question and answer, and details I included for the issue: // // http://stackoverflow.com/a/11493752/489607 // http://code.google.com/p/android/issues/detail?id=34833 // // Of course, suggestions welcome. final DatePickerDialog picker = new DatePickerDialog(getActivity(), getConstructorListener(), year, month, day); if (hasJellyBeanAndAbove()) { picker.setButton(DialogInterface.BUTTON_POSITIVE, getActivity().getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { DatePicker dp = picker.getDatePicker(); mListener.onDateSet(dp, dp.getYear(), dp.getMonth(), dp.getDayOfMonth()); } }); picker.setButton(DialogInterface.BUTTON_NEGATIVE, getActivity().getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); } return picker; }
From source file:com.app.afridge.ui.fragments.DatePickerDialogFragment.java
@TargetApi(11) @Override// w ww . jav a2 s. c o m public Dialog onCreateDialog(Bundle savedInstanceState) { Bundle b = getArguments(); int y = b.getInt(YEAR); int m = b.getInt(MONTH); int d = b.getInt(DATE); // Jelly Bean introduced a bug in DatePickerDialog (and possibly // TimePickerDialog as well), and one of the possible solutions is // to postpone the creation of both the listener and the BUTTON_* . // // Passing a null here won't harm because DatePickerDialog checks for a null // whenever it reads the listener that was passed here. >>> This seems to be // true down to 1.5 / API 3, up to 4.1.1 / API 16. <<< No worries. For now. // // See my own question and answer, and details I included for the issue: // // http://stackoverflow.com/a/11493752/489607 // http://code.google.com/p/android/issues/detail?id=34833 // // Of course, suggestions welcome. final DatePickerDialog picker = new DatePickerDialog(getActivity(), getConstructorListener(), y, m, d); if (hasJellyBeanAndAbove()) { picker.setButton(DialogInterface.BUTTON_POSITIVE, getActivity().getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { DatePicker dp = picker.getDatePicker(); mListener.onDateSet(dp, dp.getYear(), dp.getMonth(), dp.getDayOfMonth()); } }); picker.setButton(DialogInterface.BUTTON_NEGATIVE, getActivity().getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); } return picker; }
From source file:com.dycody.android.idealnote.utils.date.DatePickerDialogFragment.java
@NonNull @Override//w w w. jav a 2s .c o m public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current date as the default date in the picker Calendar cal = DateUtils.getCalendar(defaultDate); int y = cal.get(Calendar.YEAR); int m = cal.get(Calendar.MONTH); int d = cal.get(Calendar.DAY_OF_MONTH); // Jelly Bean introduced a bug in DatePickerDialog (and possibly // TimePickerDialog as well), and one of the possible solutions is // to postpone the creation of both the listener and the BUTTON_* . // // Passing a null here won't harm because DatePickerDialog checks for a null // whenever it reads the listener that was passed here. >>> This seems to be // true down to 1.5 / API 3, up to 4.1.1 / API 16. <<< No worries. For now. // // See my own question and answer, and details I included for the issue: // // http://stackoverflow.com/a/11493752/489607 // http://code.google.com/p/android/issues/detail?id=34833 // // Of course, suggestions welcome. final DatePickerDialog picker = new DatePickerDialog(getActivity(), DatePickerDialog.THEME_HOLO_LIGHT, getConstructorListener(), y, m, d); picker.setTitle(""); if (hasJellyBeanAndAbove()) { picker.setButton(DialogInterface.BUTTON_POSITIVE, getActivity().getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { DatePicker dp = picker.getDatePicker(); mListener.onDateSet(dp, dp.getYear(), dp.getMonth(), dp.getDayOfMonth()); } }); picker.setButton(DialogInterface.BUTTON_NEGATIVE, getActivity().getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); } return picker; }
From source file:ca.ualberta.cs.shoven_habittracker.DatePickerFragment.java
@Override public void onDateSet(DatePicker datePicker, int year, int month, int day) { TextView textView = (TextView) getActivity().findViewById(R.id.pickDateTextView); String monthStr = "0" + (datePicker.getMonth() + 1); String dayStr = "0" + datePicker.getDayOfMonth(); textView.setText(datePicker.getYear() + "-" + monthStr.substring(monthStr.length() - 2) + "-" + dayStr.substring(dayStr.length() - 2)); }
From source file:br.com.heitorcolangelo.mobilereport.DatePickerDialogFragment.java
@TargetApi(11) @Override/* w ww . j a va 2s .c o m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { // Jelly Bean introduced a bug in DatePickerDialog (and possibly // TimePickerDialog as well), and one of the possible solutions is // to postpone the creation of both the listener and the BUTTON_* . // // Passing a null here won't harm because DatePickerDialog checks for a null // whenever it reads the listener that was passed here. >>> This seems to be // true down to 1.5 / API 3, up to 4.1.1 / API 16. <<< No worries. For now. // // See my own question and answer, and details I included for the issue: // // http://stackoverflow.com/a/11493752/489607 // http://code.google.com/p/android/issues/detail?id=34833 // // Of course, suggestions welcome. final DatePickerDialog picker = new DatePickerDialog(getActivity(), getConstructorListener(), year, month, day); if (hasJellyBeanAndAbove()) { picker.setButton(DialogInterface.BUTTON_POSITIVE, getActivity().getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { DatePicker dp = picker.getDatePicker(); mListener.onDateSet(dp, dp.getYear(), dp.getMonth(), dp.getDayOfMonth()); } }); picker.setButton(DialogInterface.BUTTON_NEGATIVE, getActivity().getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Quando cancela no retorna nenhuma data. DatePicker dp = picker.getDatePicker(); mListener.onDateSet(dp, 0, 0, 0); } }); } return picker; }
From source file:com.gatesnfc.existing.DatePicker_Fix.java
@TargetApi(11) @Override//from ww w .j a va 2 s.c o m public Dialog onCreateDialog(Bundle savedInstanceState) { // Jelly Bean introduced a bug in DatePickerDialog (and possibly // TimePickerDialog as well), and one of the possible solutions is // to postpone the creation of both the listener and the BUTTON_* . // // Passing a null here won't harm because DatePickerDialog checks for a null // whenever it reads the listener that was passed here. >>> This seems to be // true down to 1.5 / API 3, up to 4.1.1 / API 16. <<< No worries. For now. // // See my own question and answer, and details I included for the issue: // // http://stackoverflow.com/a/11493752/489607 // http://code.google.com/p/android/issues/detail?id=34833 // // Of course, suggestions welcome. final DatePickerDialog picker = new DatePickerDialog(getActivity(), getConstructorListener(), year, month, day); if (hasJellyBeanAndAbove()) { /* * Restriction of Date from 1980 Jan 1st to Current Date */ Calendar c = Calendar.getInstance(); picker.getDatePicker().setMaxDate(c.getTimeInMillis()); c.set(Calendar.YEAR, 1980); c.set(Calendar.MONTH, c.getMinimum(Calendar.MONTH)); c.set(Calendar.DATE, c.getMinimum(Calendar.DATE)); c.set(Calendar.HOUR_OF_DAY, c.getMinimum(Calendar.HOUR_OF_DAY)); c.set(Calendar.MINUTE, c.getMinimum(Calendar.MINUTE)); c.set(Calendar.SECOND, c.getMinimum(Calendar.SECOND)); c.set(Calendar.MILLISECOND, c.getMinimum(Calendar.MILLISECOND)); picker.getDatePicker().setMinDate(c.getTimeInMillis()); picker.setButton(DialogInterface.BUTTON_POSITIVE, getActivity().getString(android.R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { DatePicker dp = picker.getDatePicker(); mListener.onDateSet(dp, dp.getYear(), dp.getMonth(), dp.getDayOfMonth()); } }); picker.setButton(DialogInterface.BUTTON_NEGATIVE, getActivity().getString(android.R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); } return picker; }
From source file:com.facebook.react.tests.DatePickerDialogTestCase.java
public void testPresetDate() { final WritableMap options = new WritableNativeMap(); options.putDouble("date", getDateInMillis(2020, 5, 6)); final DialogFragment datePickerFragment = showDialog(options); final DatePicker datePicker = ((DatePickerDialog) datePickerFragment.getDialog()).getDatePicker(); assertEquals(2020, datePicker.getYear()); assertEquals(5, datePicker.getMonth()); assertEquals(6, datePicker.getDayOfMonth()); }
From source file:com.flowzr.activity.DateFilterActivity.java
private void setDialogResult(Dialog d, Calendar c) { DatePicker dp = (DatePicker) d.findViewById(R.id.date); c.set(Calendar.YEAR, dp.getYear()); c.set(Calendar.MONTH, dp.getMonth()); c.set(Calendar.DAY_OF_MONTH, dp.getDayOfMonth()); TimePicker tp = (TimePicker) d.findViewById(R.id.time); c.set(Calendar.HOUR_OF_DAY, tp.getCurrentHour()); c.set(Calendar.MINUTE, tp.getCurrentMinute()); updateDate();/* w ww . ja v a 2 s. com*/ }
From source file:at.florian_lentsch.expirysync.AddProductActivity.java
/** * Creates a {@link ProductEntry} from the form data * /* w ww. j a v a 2 s.c o m*/ * @param article * the article associated with the entry * @return the requested {@link ProductEntry} */ private ProductEntry createProductEntryFromFormData(Article article) { final ProductEntry productEntry = new ProductEntry(); productEntry.article = article; EditText amountField = ((EditText) findViewById(R.id.amount_field)); String amountStr = amountField.getText().toString(); if (amountStr.trim().equals("")) { amountStr = DEFAULT_AMOUNT; } productEntry.amount = Integer.parseInt(amountStr); productEntry.created_at = new DateTime(); productEntry.updated_at = new DateTime(); productEntry.description = ((EditText) findViewById(R.id.product_description_field)).getText().toString(); DatePicker datePicker = (DatePicker) findViewById(R.id.expiration_date_field); productEntry.expiration_date = (new GregorianCalendar(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth())).getTime(); productEntry.location = ProductListActivity.currentLocation; productEntry.inSync = false; return productEntry; }