0

convert minute to second java

asked 2015-06-17 20:13:03 +0800

Fzacraoui gravatar image Fzacraoui
1 2

Hi, please how can convert minute to second?

delete flag offensive retag edit

Comments

multiply by 60?

chillworld ( 2015-06-17 20:49:15 +0800 )edit

it doesn't work in java

Fzacraoui ( 2015-06-17 21:17:03 +0800 )edit

i use this int depM = (int) (depassement%60); int depH = (int) (depassement/60); // to convert minut to hours and it gives me something like that hh:mm , now i need to do something like that to convert minute to second ?

Fzacraoui ( 2015-06-18 11:46:29 +0800 )edit

depassement is your total minutes right? So if you want to have total seconds it's depassement * 60. If you need hh:mm:ss => your seconds will always be 0 because you started with minutes.

chillworld ( 2015-06-18 14:01:56 +0800 )edit

Exactely i'm calculating by minutes dep is in minutes, i need to show it like that hh:mm:ss , i try to multiple by 60. but dosn't work :(

Fzacraoui ( 2015-06-18 15:29:18 +0800 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2015-06-17 21:40:44 +0800

WilliamB gravatar image WilliamB
1609 1 6

updated 2015-06-17 21:41:31 +0800

Hum not really ZK related. There is 60 seconds in a minute, so to convert minutes to seconds, you just need to multiply your minute number by 60 ?

EDIT: You say it doesnt work in Java, I'm guessing you have type issue. Can you post your code?

link publish delete flag offensive edit
0

answered 2015-06-18 02:01:02 +0800

cor3000 gravatar image cor3000
6280 2 7

updated 2015-06-18 02:06:25 +0800

To get rid of all those ugly 1000 * 60 * 60 * 24 ... and the like:

you can use the jdk built-in TimeUnit class to convert between arbitrary time units:

long seconds = java.util.concurrent.TimeUnit.MINUTES.toSeconds(5);
//seconds -> 300

just in case you're not aware of that

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2015-06-17 20:13:03 +0800

Seen: 17 times

Last updated: Jun 18 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More