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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:51:44+00:00 2026-06-01T07:51:44+00:00

I have faced the same problem many times. The Same Problem was With This

  • 0

I have faced the same problem many times.

The Same Problem was With This Question and Got Solution Like the Same,
How to compare known hours ad current hour in android?

Problem :

When I use Calendar calCurr = Calendar.getInstance(); to get the Calendar object of current date and time, It always return me wrong.

I have put logs and checked it and to make it correct I had to add in years and months and then I got the correct object for Current Date and Time.

See My Example :

    Calendar calCurr = Calendar.getInstance();
    Log.i("Time in mili of Current - Normal", ""+calCurr.getTimeInMillis()); 
                // see what it gives? dont know why?

    Date date = new Date();
    calCurr.set(date.getYear()+1900, date.getMonth()+1, date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds());
                // so added one month to it

    Log.i("Time in mili of Current - after update", ""+calCurr.getTimeInMillis()); 
                // now get correct

Question :

  • Why it’s giving the wrong output?
  • Is it a bug in there or My concept about the Calendar class is wrong?
  • tell me what should have been done
    for that?
  • 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-01T07:51:46+00:00Added an answer on June 1, 2026 at 7:51 am

    It works perfectly as expected if you change to getDate() it outputs :

    Time in mili of Current – Normal Wed Apr 04 11:34:34 BST 2012

    Time in mili of Current – after update Fri May 04 11:34:34 BST 2012

    What do you expect ? And in milleseconds it also equals 30 days :

    Time in mili of Current – Normal 1333535834557

    Time in mili of Current – after update 1336127834557

    and the calculation is (difference, divided by milliseconds in a day) :

    1336127834557 - 1333535834557 = 2 592 000 000
    
    2592000000 / 86400000 = 30
    

    And todays date in milliseconds after 1970 is 1333536754 … which fits, I don’t see a problem.

    EDIT

    Your Problem is you are setting Month like 3 for march…there you need to set 2..cause months are indexed from 0 to 11.

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

Sidebar

Related Questions

I have several times ran into the same problem, and I would like to
I have faced this problem quite often during the last couple of months, during
Today I faced a strange problem. I have an application which is the same
Hello I faced the same problem I have 1 broadcast receiver from that I
This is the most irritating problem I have ever faced: var appslst = [];
I have a problem that I have not faced before: It seems that the
We have recently been faced with the problem of porting our C++ framework to
I have designed a custom section handler before but I'm faced with a problem
I faced an interesting problem today. I have 4 strings which I need to
We've faced strange problem. We have log on service, that authenticates user, adds auth

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.