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

  • Home
  • SEARCH
  • 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 8704211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:02:54+00:00 2026-06-13T03:02:54+00:00

I have 2 datepickers and 2 timepickers on a screen and also a submit

  • 0

I have 2 datepickers and 2 timepickers on a screen and also a submit button. The user selects the start date, start time, end date, and end time. The program then takes these values and stores them into variables, however the variables only return the default values for these controls. Is there anyway to get the updated value from each of these controls?

My code looks like this for the edit screen:

public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.editscreen);

    timepickerStart = (TimePicker)findViewById(R.id.timePicker1);
    timepickerEnd = (TimePicker)findViewById(R.id.timePicker2);
    datepickerStart = (DatePicker)findViewById(R.id.datePicker1);
    datepickerEnd = (DatePicker)findViewById(R.id.datePicker2);

    submitbutton = (Button)findViewById(R.id.submit);

    locationText = (EditText)findViewById(R.id.locationText);
    eventText = (EditText)findViewById(R.id.eventText);

}

public void DateStart(View v)
{
    GlobalVariables.datepickerYearStart = datepickerStart.getYear();
    GlobalVariables.datepickerMonthStart = datepickerStart.getMonth();
    GlobalVariables.datepickerDayStart = datepickerStart.getDayOfMonth();
}

public void DateEnd(View v)
{
    GlobalVariables.datepickerYearEnd = datepickerEnd.getYear();
    GlobalVariables.datepickerMonthEnd = datepickerEnd.getMonth();
    GlobalVariables.datepickerDayEnd = datepickerEnd.getDayOfMonth();
}

public void TimeStart(View v)
{
    GlobalVariables.timepickerHourStart = timepickerStart.getCurrentHour();
    GlobalVariables.timepickerMinuteStart = timepickerStart.getCurrentMinute();
}

public void TimeEnd(View v)
{
    GlobalVariables.timepickerHourEnd = timepickerEnd.getCurrentHour();
    GlobalVariables.timepickerMinuteEnd = timepickerEnd.getCurrentMinute();
}

public void submitClicked(View v)
{

    startActivity(new Intent(this, AddToCalendar.class));
}
  • 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-13T03:02:56+00:00Added an answer on June 13, 2026 at 3:02 am

    Rewrite

    Looking at your current code, let’s stick with the various get methods from DatePicker and TimePicker. However you never call DateStart() or any of the others, they look like you have them set up for an OnClickListener… Regardless, try this:

    public void submitClick(View v) {
        DateStart(null);
        TimeStart(null);
        DateEnd(null);
        TimeEnd(null);
    
        // Do what you please your GlobalVariables
    }
    

    Though I might leave out the multiple GlobalVariables and store one long value for each date/time:

    public void submitClick(View v) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(datepickerStart.getYear(), datepickerStart.getMonth(),
                     datepickerStart.getDayOfMonth(), timepickerStart.getCurrentHour(), 
                     timepickerStart.getCurrentMinute(), 0);
        long startTime = calendar.getTimeInMillis();
    
        // And similar approach for the end time, then use them however you please
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two datepickers. When start date is selected, end date is automatically assigned
I have two datepickers at the moment, one for a start date, and another
I have two datepickers where the user makes a selection. Then for each day
I have multiple datepickers in one page. I user class name to set the
We have a request from many customers to make our datepickers reflect the date
I am using Jquery Date pickers to get Start and End Dates for an
I have Date and Time from DatePicker and TimePicker . Now i want to
In my app I have 2 buttons which opens a Time Dialog/Date Dialog and
i have to select a interval of time. i have two timepickers on my
I have this code from where I can set a time and date from

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.