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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:52:08+00:00 2026-06-01T00:52:08+00:00

I have a datepicker, and I pick up two dates, like 2012-04-08 and 2012-05-11.

  • 0

I have a datepicker, and I pick up two dates, like 2012-04-08 and 2012-05-11. Because I have a database and need store dates as strings I convert them to 20120408 and 20120511 (strings so far). My code contains the next steps. I call my function with these strings:

public void durva(String datefrom, String dateto) throws ParseException {

    datefrom = GlobalVars.getDateStringFrom();
    dateto = GlobalVars.getDateStringTo();

    Log.i("DateFrom", datefrom);
    Log.i("Dateto", dateto);

    SimpleDateFormat formatter2 = new SimpleDateFormat("yyyyMMdd"); //-de most yyMMdd
    formatter2.setLenient(false);

    Date dates1;
    Date dates2;
    long mili1;
    long mili2;

    long diff;

    String dates="";
        String convertedDates = "";

    dates1 = formatter2.parse(datefrom);
           mili1 = dates1.getTime(); 
           Log.i("date1",  String.valueOf(mili1));
   dates2 = formatter2.parse(dateto);
           mili2 = dates2.getTime(); 
           Log.i("date2",  String.valueOf(mili2));

   diff = 1+((mili2-mili1)/86400000);

   Log.i("diff",  String.valueOf(diff));

   long [] millis = new long[(int) diff];


   for (int i=0;i<diff;i++)
    {
        millis[i] = mili1+(86400000*i);
         Log.i("millii",  String.valueOf(millis[i]));
    dates = dates + String.valueOf(millis[i]) + " ";   


    SimpleDateFormat formatterX = new SimpleDateFormat("yyyyMMdd"); 
    String dateString = formatterX.format(new Date(millis[i]));

          convertedDates = convertedDates + dateString + " ";
    }
      Log.i("DATES",  convertedDates);
      } 

I use the a created GlobalVars when I pick a date and covert them to this string format I mentioned above. Then I convert them to millisecs. Then I convert them back to my format but it is not important, since the millisecs are already messed up. With

for (int i=0;i<diff;i++)
        {
            millis[i] = mili1+(86400000*i);
             Log.i("millii",  String.valueOf(millis[i]));

I always increase the millisecs, but what happens after the 25th value? It travels back in time and continues from another value! In this example I get: 20120408 20120409 .. 20120502 20120314..20120322 . I add 86400000 (millisecs per day) for jumping a whole day.
What’s happening here?
Thank you in advance!

  • 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-01T00:52:09+00:00Added an answer on June 1, 2026 at 12:52 am

    You should use 86400000L, or declare i as long:

    millis[i] = mili1+(86400000L*i);
    

    Otherwise both i and 86400000 are 32 bit integers, so the result is calculated as a 32-bit integer. Unfortunately 86400000*25 is too big to fit in 32 bits, so it wraps around.

    86400000*25 is -2134967296.

    Another thing you should be careful about is that not all days have 24 hours thanks to DST.

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

Sidebar

Related Questions

i have an a jquery ui datepicker and i need to pick the date
I have a datepicker and it can not allow dates prior to today VIA
I am developing an application in that i have used DatePicker to pick the
I have my datepicker set up like this $(#scheduled_date_163).datepicker({ onSelect: function(dateText, inst) { jQuery.get(/tasks/inplace_edit?id=scheduled_date_163&class_name=Task&value=
ok so i have a datepicker and the initial state is like this Jul.
Basically I'm using datepicker from jQuery to have my client pick a date. I
I have a DatePicker d; and I need to get the milliseconds value of
I'm currently working with jQuery and using the datepicker. I have two input fields:
I'm using the JQuery DatePicker to have the user pick a date and have
I currently have datepicker only allowing Fridays. I would like to continue to only

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.