Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7635471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:26:04+00:00 2026-05-31T07:26:04+00:00

I am using a standard date picker to allow the user to pick a

  • 0

I am using a standard date picker to allow the user to pick a date. After this I will then calculate the days between the current date and the date which was picked.

The problem is when the date picker is fired off the app crashes, even though I had it working before i put in the joda time API. The code I am using for the date picker is:-

mDateDisplay = (TextView) findViewById(R.id.dateDisplay);
    mPickDate = (Button) findViewById(R.id.pickDate);
    // add a click listener to the button
    mPickDate.setOnClickListener(new View.OnClickListener(){
        public void onClick(View v) {
            showDialog(DATE_DIALOG_ID);
        }
    });
     //get the current date
    final Calendar c = Calendar.getInstance();
    cYear = c.get(Calendar.YEAR);
    cMonth = c.get(Calendar.MONTH);
    cDay = c.get(Calendar.DAY_OF_MONTH);
    Date past = new Date(cYear, cMonth, cDay); // current Date
    Date today = new Date(mYear, mMonth, mDay); // date Choosen by the user
    int days = Days.daysBetween(new DateTime(past), new DateTime(today)).getDays();
    mDateDisplay.setText(""+days);
 private DatePickerDialog.OnDateSetListener mDateSetListener =
            new DatePickerDialog.OnDateSetListener() {

                public void onDateSet(DatePicker view, int year, 
                                      int monthOfYear, int dayOfMonth) {
                    mYear = year;
                    mMonth = monthOfYear;
                    mDay = dayOfMonth;
                    //updateDisplay();
                }
            };
           @Override
            protected Dialog onCreateDialog(int id) {
                switch (id) {
                case DATE_DIALOG_ID:
                    return new DatePickerDialog(this,
                                mDateSetListener,
                                mYear, mMonth, mDay);
                }
                return null;
            }

I have an updateDisplay() method which is being references but I have commented everything to do with it out because I don’t think I need it for what I am trying to do. For those interested here it is:

private void updateDisplay() {
        mDateDisplay.setText(
            new StringBuilder()
                    // Month is 0 based so add 1
                    .append(mMonth + 1).append("-")
                    .append(mDay).append("-")
                    .append(mYear).append(" "));
   }

People asked for the logcat output here is is

03-17 17:47:42.343: E/AndroidRuntime(8122): FATAL EXCEPTION: main
03-17 17:47:42.343: E/AndroidRuntime(8122): java.lang.IllegalArgumentException: current should be >= start and <= end
03-17 17:47:42.343: E/AndroidRuntime(8122): at android.widget.NumberPicker.setCurrent(NumberPicker.java:288)
03-17 17:47:42.343: E/AndroidRuntime(8122): at android.widget.DatePicker.updateDaySpinner(DatePicker.java:364)
03-17 17:47:42.343: E/AndroidRuntime(8122): at android.widget.DatePicker.updateSpinners(DatePicker.java:350)
03-17 17:47:42.343: E/AndroidRuntime(8122): at android.widget.DatePicker.init(DatePicker.java:346)
03-17 17:47:42.343: E/AndroidRuntime(8122): at android.app.DatePickerDialog.(DatePickerDialog.java:124)
03-17 17:47:42.343: E/AndroidRuntime(8122): at android.app.DatePickerDialog.(DatePickerDialog.java:83)
03-17 17:47:42.343: E/AndroidRuntime(8122): at com.b00348312.workout.WorkoutChoice.onCreateDialog(WorkoutChoice.java:113)
03-17 17:47:42.343: E/AndroidRuntime(8122): at android.app.Activity.onCreateDialog(Activity.java:2513)
03-17 17:47:42.343: E/AndroidRuntime(8122): at android.app.Activity.createDialog(Activity.java:888)
03-17 17:47:42.343: E/AndroidRuntime(8122): at android.app.Activity.showDialog(Activity.java:2588)
03-17 17:47:42.343: E/AndroidRuntime(8122): at android.app.Activity.showDialog(Activity.java:2555)
03-17 17:47:42.343: E/AndroidRuntime(8122): at com.b00348312.workout.WorkoutChoice$2.onClick(WorkoutChoice.java:49)
03-17 17:47:42.343: E/AndroidRuntime(8122): at android.view.View.performClick(View.java:2408)
03-17 17:47:42.343: E/AndroidRuntime(8122): at android.view.View$PerformClick.run(View.java:8817)
03-17 17:47:42.343: E/AndroidRuntime(8122): at android.os.Handler.handleCallback(Handler.java:587)
03-17 17:47:42.343: E/AndroidRuntime(8122): at android.os.Handler.dispatchMessage(Handler.java:92)
03-17 17:47:42.343: E/AndroidRuntime(8122): at android.os.Looper.loop(Looper.java:144)
03-17 17:47:42.343: E/AndroidRuntime(8122): at android.app.ActivityThread.main(ActivityThread.java:4937)
03-17 17:47:42.343: E/AndroidRuntime(8122): at java.lang.reflect.Method.invokeNative(Native Method)
03-17 17:47:42.343: E/AndroidRuntime(8122): at java.lang.reflect.Method.invoke(Method.java:521)
03-17 17:47:42.343: E/AndroidRuntime(8122): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
03-17 17:47:42.343: E/AndroidRuntime(8122): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
03-17 17:47:42.343: E/AndroidRuntime(8122): at dalvik.system.NativeStart.main(Native Method)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T07:26:05+00:00Added an answer on May 31, 2026 at 7:26 am

    you can see the example here that i have put the date and time picker dialog and set it to the textView

    http://typicaljava.blogspot.in/2012/02/date-picker-time-picker-dialog-and-set.html

    Hope this might helps you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the standard asp:Calendar control. When a user clicks a date, I
Is there any reason behind using date(January 1st, 1970) as default standard for time
Using standard mysql functions is there a way to write a query that will
Im using date.js to compare to dates that are written in user friendly string
I have a standard Jquery date picker which shows 2 textboxes. One textbox has
I am trying to add days to a given date using Javascript. I have
I'm using the Date Picker from the Telerik MVC library. It appears and works
I have an TextBlock showing a date using the standard short date format for
DateTime's formatting has some overlap between it'a standard date and time formatting strings and
No this is not the standard +86400 seconds between dates. $start_time = strtotime(2012-01-15 23:59);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.