GuiSim
GuiSim

Reputation: 7569

Obtaining the number of standard seconds in a minute with JodaTime

I need to obtain an integer, long or double that represents the number of standard seconds contained in a given number of standard minutes.

1 minute => 60 seconds
2 minutes => 120 seconds
..

What is the preferred way of obtaining the number of standard seconds within a minute using JodaTime?

So far, I've been using this:

Minutes.minutes(2).toStandardSeconds().getSeconds()

I find ".getSeconds()" to be slightly redundant.

In C#, I would have used

TimeSpan.FromMinutes(2).TotalSeconds

Is there something similar in JodaTime?

Upvotes: 0

Views: 253

Answers (1)

flavian
flavian

Reputation: 28511

You can use DateTimeConstants. Specifically, you can use DateTimeConstants.SECONDS_PER_MINUTE

import org.joda.time.DateTimeConstants;
System.out.println(DateTimeConstants.SECONDS_PER_MINUTE);

Read more about available constants here..

Upvotes: 2

Related Questions