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 8528299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:46:14+00:00 2026-06-11T08:46:14+00:00

I am using a Datepicker in my application. What I am trying to do

  • 0

I am using a Datepicker in my application. What I am trying to do is getting the date already set in the text field and showing that on Datepicker control. But I am getting NumberFormatException when I use

Integer.parseInt(splittedDate[2])  //i.e the year column. 

When I see while debugging splittedDate containf three values which are fine. but while parsing year column at last index throws exception. I am unable to understand why is it so. pleasehelp me out of this. Following is the implementation of CreateDialog method for Datepicker.

@Override
protected Dialog onCreateDialog(int id) {
    if (id == DATE_DIALOG_ID) {
        if (birthDate.getText().toString().equalsIgnoreCase(""))
            return new DatePickerDialog(this, mDateSetListener, mYear,
                    mMonth, mDay);
        else {
            String[] splittedDate = birthDate.getText().toString().split("-");

            try{

                Log.i("Month String", splittedDate[0]);
                mMonth = Integer.parseInt(splittedDate[0]);
                Log.i("Day String", splittedDate[1]);
                mDay = Integer.parseInt(splittedDate[1]);
                Log.i("Year String", splittedDate[0]);
                mYear = Integer.parseInt(splittedDate[2]);

            }
            catch(Exception e)
            {
                Log.e("Number Format Exception Message: ",e.getMessage());
            }

            return new DatePickerDialog(this, mDateSetListener, mYear,
                    mMonth, mDay);

        }

    return null;
}

Here is the logCat info:

 09-05 16:21:54.722: E/AndroidRuntime(28596): FATAL EXCEPTION: main
 09-05 16:21:54.722: E/AndroidRuntime(28596): java.lang.NumberFormatException: unable to parse '1970 ' as integer
 09-05 16:21:54.722: E/AndroidRuntime(28596):   at java.lang.Integer.parse(Integer.java:383)
 09-05 16:21:54.722: E/AndroidRuntime(28596):   at java.lang.Integer.parseInt(Integer.java:372)
 09-05 16:21:54.722: E/AndroidRuntime(28596):   at java.lang.Integer.parseInt(Integer.java:332)
 09-05 16:21:54.722: E/AndroidRuntime(28596):   at com.test.project.activity.DetailActivity.onCreateDialog(DetailActivity.java:332)
  • 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-06-11T08:46:15+00:00Added an answer on June 11, 2026 at 8:46 am

    Post the code where you are inserting values in birthDate field. Check that there should not be any blank spaces. There should be digits only. from the Exception, it seems that '1970 ' contains a blank space. double check the birthDate field..

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

Sidebar

Related Questions

Im using the Datepicker control to get a date and display it in a
I'm using a datepicker in my mvc3 application. the problem is that the controls
I'm using jQuery's datepicker plugin in .NET ASP MVC3 intranet application. User that use
I am using jquery datepicker for my application. I want to highlight the dates
I am using the following in my application DatePicker from jQuery UI Pretty Photo.
I am using bootstrap-datepicker and get a value of 1339698600000 for the selected date
I'm using jQuery Datepicker but I'm having trouble when editing records. // js code
I am using the datepicker which renders incorrectly on my webpage. The date rows
Im using DatePicker plugin for a project. But I want to Disable dates older
I am using Jquery Datepicker in my application. It is working fine on all

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.