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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:12:22+00:00 2026-06-09T14:12:22+00:00

For some reason I get 2 hours in the clock while I’ve only been

  • 0

For some reason I get 2 hours in the clock while I’ve only been running it for few seconds.
Here are the results of the time stamps and the code:

08-12 01:03:47.858: I/System.out(2856): 1344722627872
08-12 01:03:51.198: I/System.out(2856): 1344722631206
08-12 01:03:54.698: I/System.out(2856): 3334
08-12 01:03:54.758: I/System.out(2856): 02:00:03




public static String getDate(long milliSeconds, String dateFormat)  {

    DateFormat formatter = new SimpleDateFormat(dateFormat);

     Calendar calendar = Calendar.getInstance();
     calendar.setTimeInMillis(milliSeconds);
     return formatter.format(calendar.getTime());   }

This is the complete code with the calling:

// Click Listener for Check In\Out Button

    checkIn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // Check Out
            myVib.vibrate(10);
            if (clicked == true) {
                timeStampWhenOut = System.currentTimeMillis();
                killcheck = true;
                checkedStatus = "Check In";
                checkIn.setText(checkedStatus);
                long getShiftLength = ShiftLength(timeStampWhenIn,
                        timeStampWhenOut);
                System.out.println(timeStampWhenOut);
                System.out.println(getShiftLength);
                System.out.println(getDate(getShiftLength, "hh:mm:ss"));
                clicked = false;
                wasShift = true;

                // Check In
            } else if (clicked == false) {

                timeStampWhenIn = System.currentTimeMillis();
                System.out.println(timeStampWhenIn);
                checkedStatus = "Check Out";
                checkIn.setText(checkedStatus);
                killcheck = false;
                clicked = true;

            }
        }
    });

Why are the hours wrong?

  • 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-09T14:12:23+00:00Added an answer on June 9, 2026 at 2:12 pm

    Assuming 3334 is an elapsed time, you’re setting the Calendar to 3.334 seconds since the epoch (approximately midnight GMT on December 31st 1970). Then you’re formatting that Calendar. And it’s telling you that it’s 2am plus 3 seconds in your time zone, by which I guess that your time zone is GMT+2.

    Don’t use Calendar and SimpleDateFormatter for elapsed times – it’s not the right tool for the job. Have a look at DurationFormatUtils in Apache-Commons instead.

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

Sidebar

Related Questions

Unfortunately, for some reason I cannot fathom, I haven't been able to get windbg
I have been working on this for the past 5 hours. For some reason
I've been trying to get this code to work for a few hours now
This is kind of embarrassing but I cannot for some reason get his CSS
For some reason I get some warnings about non dll-interface class when building with
I have a search setup inside a div but for some reason cannot get
I can run the following query in PHPMyAdmin, but for some reason I get
I use CSS transitions fairly regularly and for some reason I cannot get them
For some reason I can't get this to work. It pulls the name and
For some reason I can't get this script to run when I add the

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.