org.sonar.api.utils
Class Duration

java.lang.Object
  extended by org.sonar.api.utils.Duration
All Implemented Interfaces:
Serializable

public class Duration
extends Object
implements Serializable

Since:
4.3
See Also:
Serialized Form

Field Summary
static String DAY
           
static String HOUR
           
static String MINUTE
           
 
Method Summary
 Duration add(Duration with)
          Add the given duration to the current one.
static Duration create(long durationInMinutes)
          Create a Duration from a number of minutes.
static Duration decode(String text, int hoursInDay)
          Create a Duration from a text duration and the number of hours in a day.
 String encode(int hoursInDay)
          Return the duration in text, by using the given hours in day parameter to process hours.
 boolean equals(Object o)
           
 int hashCode()
           
 boolean isGreaterThan(Duration other)
          Return true if the given duration is greater than the current one.
 Duration multiply(int factor)
          Multiply the duration with the given factor.
 Duration subtract(Duration with)
          Subtract the given duration to the current one.
 long toMinutes()
          Return the duration in minutes.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DAY

public static final String DAY
See Also:
Constant Field Values

HOUR

public static final String HOUR
See Also:
Constant Field Values

MINUTE

public static final String MINUTE
See Also:
Constant Field Values
Method Detail

create

public static Duration create(long durationInMinutes)
Create a Duration from a number of minutes.


decode

public static Duration decode(String text,
                              int hoursInDay)
Create a Duration from a text duration and the number of hours in a day.
For instance, Duration.decode("1d 1h", 8) will have a number of minutes of 540 (1*8*60 + 60).


encode

public String encode(int hoursInDay)
Return the duration in text, by using the given hours in day parameter to process hours.
Duration.decode("1d 1h", 8).encode(8) will return "1d 1h" Duration.decode("2d", 8).encode(16) will return "1d"


toMinutes

public long toMinutes()
Return the duration in minutes.
For instance, Duration.decode(1h, 24).toMinutes() will return 60.


isGreaterThan

public boolean isGreaterThan(Duration other)
Return true if the given duration is greater than the current one.


add

public Duration add(Duration with)
Add the given duration to the current one.


subtract

public Duration subtract(Duration with)
Subtract the given duration to the current one.


multiply

public Duration multiply(int factor)
Multiply the duration with the given factor.


equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009–2016 SonarSource. All rights reserved.