Converting a float to minutes and seconds

Hey there!

This is a quick question really.

I have a float (lets say 520) which represents the number of seconds in a journey.

I'm wanting to give a time for that journey in seconds (in the format xx minutes xx seconds) so in this case (520 seconds), it would be "8 minutes 40 seconds".

Are there a few simple lines of code that can do this please?

I've had a Google at it but I'm mostly getting back API stuff on Time and Date.

Thanks in advance.
Who is Participating?
Formatted per your style:

System.out.printf("%d minutes %d seconds\n", (int)(f /60), (int)(f % 60));
long l = 520;

String time = ""+(l/60)+"m "+(l%60)+"s";
int mins = (int)(f / 60);
int secs = (int)(f % 60);
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

oh, You said float, then simply cast it to long:

long l = (long) _any_float_here_
DanBAtkinsonAuthor Commented:
I'd like to split the points here to CEHJ because they supplied an answer which was in the style I asked and it's in one line.

But I'll also award points to StillUnAware for the speed and the fact that his is also correct.

100 to StillUnAware as an assist
400 to CEHJ for the correct answer
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.