Package org.elasticsearch.common.unit
Class TimeValue
java.lang.Object
org.elasticsearch.common.unit.TimeValue
- All Implemented Interfaces:
java.lang.Comparable<TimeValue>
public class TimeValue extends java.lang.Object implements java.lang.Comparable<TimeValue>
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description int
compareTo(TimeValue timeValue)
long
days()
double
daysFrac()
long
duration()
boolean
equals(java.lang.Object o)
long
getDays()
double
getDaysFrac()
long
getHours()
double
getHoursFrac()
long
getMicros()
double
getMicrosFrac()
long
getMillis()
double
getMillisFrac()
long
getMinutes()
double
getMinutesFrac()
long
getNanos()
long
getSeconds()
double
getSecondsFrac()
java.lang.String
getStringRep()
int
hashCode()
long
hours()
double
hoursFrac()
long
micros()
double
microsFrac()
long
millis()
double
millisFrac()
long
minutes()
double
minutesFrac()
long
nanos()
static long
nsecToMSec(long ns)
static TimeValue
parseTimeValue(java.lang.String sValue, java.lang.String settingName)
static TimeValue
parseTimeValue(java.lang.String sValue, TimeValue defaultValue, java.lang.String settingName)
long
seconds()
double
secondsFrac()
java.util.concurrent.TimeUnit
timeUnit()
static TimeValue
timeValueDays(long days)
static TimeValue
timeValueHours(long hours)
static TimeValue
timeValueMillis(long millis)
static TimeValue
timeValueMinutes(long minutes)
static TimeValue
timeValueNanos(long nanos)
static TimeValue
timeValueSeconds(long seconds)
java.lang.String
toHumanReadableString(int fractionPieces)
Returns aString
representation of the currentTimeValue
.java.lang.String
toString()
Returns aString
representation of the currentTimeValue
.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Field Details
-
NSEC_PER_MSEC
public static final long NSEC_PER_MSECHow many nano-seconds in one milli-second -
MINUS_ONE
-
ZERO
-
MAX_VALUE
-
-
Constructor Details
-
TimeValue
public TimeValue(long millis) -
TimeValue
public TimeValue(long duration, java.util.concurrent.TimeUnit timeUnit)
-
-
Method Details
-
timeValueNanos
-
timeValueMillis
-
timeValueSeconds
-
timeValueMinutes
-
timeValueHours
-
timeValueDays
-
timeUnit
public java.util.concurrent.TimeUnit timeUnit()- Returns:
- the unit used for the this time value, see
duration()
-
duration
public long duration()- Returns:
- the number of
timeUnit()
units this value contains
-
nanos
public long nanos() -
getNanos
public long getNanos() -
micros
public long micros() -
getMicros
public long getMicros() -
millis
public long millis() -
getMillis
public long getMillis() -
seconds
public long seconds() -
getSeconds
public long getSeconds() -
minutes
public long minutes() -
getMinutes
public long getMinutes() -
hours
public long hours() -
getHours
public long getHours() -
days
public long days() -
getDays
public long getDays() -
microsFrac
public double microsFrac() -
getMicrosFrac
public double getMicrosFrac() -
millisFrac
public double millisFrac() -
getMillisFrac
public double getMillisFrac() -
secondsFrac
public double secondsFrac() -
getSecondsFrac
public double getSecondsFrac() -
minutesFrac
public double minutesFrac() -
getMinutesFrac
public double getMinutesFrac() -
hoursFrac
public double hoursFrac() -
getHoursFrac
public double getHoursFrac() -
daysFrac
public double daysFrac() -
getDaysFrac
public double getDaysFrac() -
toString
public java.lang.String toString()Returns aString
representation of the currentTimeValue
. Note that this method might produce fractional time values (ex 1.6m) which cannot be parsed by method likeparse(String, String, String, String)
. Also note that the maximum string value that will be generated is106751.9d
due to the way that values are internally converted to nanoseconds (106751.9 days is Long.MAX_VALUE nanoseconds)- Overrides:
toString
in classjava.lang.Object
-
toHumanReadableString
public java.lang.String toHumanReadableString(int fractionPieces)Returns aString
representation of the currentTimeValue
. Note that this method might produce fractional time values (ex 1.6m) which cannot be parsed by method likeparse(String, String, String, String)
. The number of fractional decimals (up to 10 maximum) are truncated to the number of fraction pieces specified. Also note that the maximum string value that will be generated is106751.9d
due to the way that values are internally converted to nanoseconds (106751.9 days is Long.MAX_VALUE nanoseconds)- Parameters:
fractionPieces
- the number of decimal places to include
-
getStringRep
public java.lang.String getStringRep() -
parseTimeValue
-
parseTimeValue
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-
nsecToMSec
public static long nsecToMSec(long ns) -
compareTo
- Specified by:
compareTo
in interfacejava.lang.Comparable<TimeValue>
-