JavaHow to Convert Second to Microseconds in Java

How to Convert Second to Microseconds in Java content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

There are some instances where a developer may need to convert seconds into smaller fractions of time – such as a microsecond. In the example code below, we show programmers how to convert seconds to microseconds using Java and the TimeUnit enum:


import java.util.concurrent.*;

public class ConvertingToMicroseconds
	public static void main(String args[])
		ConvertingToMicroseconds ConvertingToMicroseconds = new ConvertingToMicroseconds();
	private void proceed()
		System.out.println("1 second(s) --> " + TimeUnit.MICROSECONDS.convert(1L, TimeUnit.SECONDS) + " microsecond(s)");


You can expect the following output when you run this Java code:

[root@mypc]# java ConvertingToMicroseconds
1 second(s) --> 1000000 microsecond(s)

Read: Java Quick Tip: List All Files in a Directory by Type

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Latest Posts

Related Stories