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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:27:00+00:00 2026-06-02T23:27:00+00:00

My problem at present is that the values obtained from the DatePickerDialog are not

  • 0

My problem at present is that the values obtained from the DatePickerDialog are not getting parsed correctly when I send them to the Date constructor.

Getting the date values (as per the suggestions from another post)….

private DatePickerDialog.OnDateSetListener listener = new DatePickerDialog.OnDateSetListener() {
    @Override
    public void onDateSet(DatePicker view, int year, int monthOfYear,
            int dayOfMonth) {
        mYear = year;
        mMonth = monthOfYear + 1;
        mDayOfMonth = dayOfMonth;
        String t = "listener => mYear=" + mYear + "; mMonth=" + mMonth +
                "; mDayOfMonth=" + mDayOfMonth + ";";
        Log.i(TAG, t);
    }
};

The above logging statement yields:

04-30 21:34:10.548: I/TodosActivity(29510): listener => mYear=2012; mMonth=5; mDayOfMonth=2;

The date is set with….

todo.setDueDate(new Date(mYear, mMonth, mDayOfMonth));

I verified the due date with….

String t = "setNewDueDate(Todo) => #" + todo.getId() + ": " + todo.getTitle() + " (" +
            todo.getText() + "). Created on " + format.format(todo.getCreatedDate()) +
            ". Last modified on " + format.format(todo.getModifiedDate()) +
            ". Due on " + format.format(todo.getDueDate()) + ".";
Log.i(TAG, t);

which resulted in….

04-30 21:34:05.703: I/TodosActivity(29510): setNewDueDate(Todo) => #1: Test (Test). Created on 30 Apr 2012 20:07:51. Last modified on 30 Apr 2012 20:55:27. Due on 31 Dec 1899 00:00:00.

EDIT:

Setting the initial DatePickerDialog values…

        return new DatePickerDialog(this, listener, cal.get(Calendar.YEAR),
                cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));

Is there anything that I should/should not have done?

  • 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-02T23:27:02+00:00Added an answer on June 2, 2026 at 11:27 pm

    Use Calendar and the various set() methods on it to update the date.

    For example, this sample project has code like this:

     DatePickerDialog.OnDateSetListener d=new DatePickerDialog.OnDateSetListener() {
        public void onDateSet(DatePicker view, int year, int monthOfYear,
                              int dayOfMonth) {
          dateAndTime.set(Calendar.YEAR, year);
          dateAndTime.set(Calendar.MONTH, monthOfYear);
          dateAndTime.set(Calendar.DAY_OF_MONTH, dayOfMonth);
          updateLabel();
        }
      };
    

    where dateAndTime is a Calendar.

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

Sidebar

Related Questions

Problem: to show that a Not-SO-page has been discussed in SO when you at
Hello I have a little problem with assigning property values from one lists items
I'll only try to present the main part of the problem, because the whole
(This is a question about a vague problem. I try to present all relevant
Problem When working with MasterPages, a common irritation I run into is that script
The problem I am facing is that I am unable to store the checked
My goal is to present a jsf page that has Create, Retrieve and Update
I have a command Get-Testdata that retrieves test data from different sources and stores
My problem is simple not so lengthy as looking like. I have 7 textboxes
Here is my problem: I have a bunch of circles that I need to

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.