# Thread: Convert microseconds to seconds

1. Member
Join Date
Aug 2009
Posts
48
Rep Power
0

## Convert microseconds to seconds

Hi,
Hope you all will be fine.I know it's a very basic question but i don't know why i am unable to doing it. Anyways i want to find a length of a .wav file, for this, i use this code but it returns length in microseconds

Java Code:
` System.out.println( clip.getMicrosecondLength() );`
and the output is

5875000

i want this to be in seconds means if i convert this to seconds it becomes 5.875 sec, so i want that when i execute this line it gives me only 6 sec after rounding of or 5 or 20 sec only, means only int value no decimal value.

I also tried this
Java Code:
`System.out.println( clip.getMicrosecondLength()/0.000001 );`
and also

Java Code:
`System.out.println( (clip.getMicrosecondLength()/0.000001)%60 );`

Thank you

2. Senior Member
Join Date
Aug 2009
Posts
2,388
Rep Power
10
Read the API specs for the Math.round method.

3. Senior Member
Join Date
Aug 2009
Posts
2,388
Rep Power
10
Originally Posted by Fubarable
Maybe my math is off, but my brain tells me that

5875000 ms / 1000 = 5875 seconds
There is a millisecond vs microsecond thing going on there.

4. Member
Join Date
Aug 2009
Posts
48
Rep Power
0
Hi,
Thank you to all for your help. Really it's very simple. Simply

Java Code:
``` /**
* Conversion in seconds. Since
* 1 microsecond = 10^(-6) sec
* 1 microsecond = 1/1000000 sec
*/
System.out.println("seconds: " + (clip.getMicrosecondLength()/1000000) );```
Thank you

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•