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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:26:31+00:00 2026-06-03T22:26:31+00:00

I am using milliseconds in my java program and converting it to seconds. After

  • 0

I am using milliseconds in my java program and converting it to seconds. After my method does this, it returns seconds in a long format.

System.out.println("[" + threadID + "]" + " " + "SeqSum res=" + grandTotal + " secs=" + stopTime);

I have used the variable stopTime to display the seconds.

My output is currently secs=0
It needs to be secs=0.000

I need it to be displayed to 3 decimal places using system.out.println() or system.out.format()

How can I reword my print statement so that I get the output secs=0.000?

Please help

  • 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-03T22:26:32+00:00Added an answer on June 3, 2026 at 10:26 pm

    Milliseconds are a long, and don’t have decimal places. You will need to divide them by 1000.0f to get them into fractional seconds. Then you will need to use the format method to limit them to 3 decimal places.

    Something like:

       final long ms;
       final float sec;
    
       ms = System.currentTimeMillis();
       sec = ms / 1000.0f;
       System.out.format("%.3f", sec);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to convert milliseconds to minutes using java.util.concurrent.TimeUnit? This answer seems
How to pause a program for a few milliseconds using C++ managed code? I
I'm familiar with printing time difference in milliseconds: long time = System.currentTimeMillis(); //do something
My program needs to represent this date as a java.sql.date object , but it
I have input, 34600 milliseconds I would like to output this in the format
I am using a Java library that has a method that wants a time
I am doing some date calculations in Java using milliseconds and noticing an issue
using (var file_stream = File.Create(users.xml)) { var serializer = new XmlSerializer(typeof(PasswordManager)); serializer.Serialize(file_stream, this); file_stream.Close();
Using Flex 3, I would like to take an image snapshot such as this:
(See this question in ServerFault ) I have a Java client that uses Socket

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.