Package com.irurueta.units
Class TimeConverter
java.lang.Object
com.irurueta.units.TimeConverter
Does time conversions to different units.
To prevent loss of accuracy, conversion should only be done as a final step
before displaying time measurements.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final doubleNumber of seconds in 1 century.(package private) static final doubleNumber of seconds in 1 day.(package private) static final doubleNumber of seconds in 1 hour.(package private) static final doubleNumber of seconds in 1 microsecond.(package private) static final doubleNumber of seconds in 1 milliseconds.(package private) static final doubleNumber of seconds in 1 minute.(package private) static final doubleNumber of seconds in 1 month.(package private) static final doubleNumber of seconds in 1 nanosecond.(package private) static final doubleNumber of seconds in 1 week.(package private) static final doubleNumber of seconds in 1 year. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doublecenturyToSecond(double century) Converts provided century value to seconds.static doubleConverts a time value from input unit to provided output unit.static voidConverts a time to provided output time unit.static voidConverts and updates a time to requested output unit.static voidConverts a time to requested output unit.static NumberConverts a time value from input unit to provided output unit.static TimeconvertAndReturnNew(Time input, TimeUnit outputUnit) Converts a time to requested output unit.static doubledayToSecond(double day) Converts provided day value to seconds.static doublehourToSecond(double hour) Converts provided hour value to seconds.static doublemicrosecondToSecond(double microsecond) Converts provided microsecond value to seconds.static doublemillisecondToSecond(double millisecond) Converts provided millisecond value to seconds.static doubleminuteToSecond(double minute) Converts provided minute value to seconds.static doublemonthToSecond(double month) Converts provided month value to seconds.static doublenanosecondToSecond(double nanosecond) Converts provided nanosecond value to seconds.static doublesecondToCentury(double second) Converts provided second value to century.static doublesecondToDay(double second) Converts provided second value to days.static doublesecondToHour(double second) Converts provided second value to hours.static doublesecondToMicrosecond(double second) Converts provided second value to microseconds.static doublesecondToMillisecond(double second) Converts provided second value to milliseconds.static doublesecondToMinute(double second) Converts provided second value to minutes.static doublesecondToMonth(double second) Converts provided second value to months.static doublesecondToNanosecond(double second) Converts provided second value to nanoseconds.static doublesecondToWeek(double second) Converts provided second value to weeks.static doublesecondToYear(double second) Converts provided second value to years.static doubleweekToSecond(double week) Converts provided week value to seconds.static doubleyearToSecond(double year) Converts provided year value to seconds.
-
Field Details
-
SECONDS_PER_NANOSECOND
static final double SECONDS_PER_NANOSECONDNumber of seconds in 1 nanosecond.- See Also:
-
SECONDS_PER_MICROSECOND
static final double SECONDS_PER_MICROSECONDNumber of seconds in 1 microsecond.- See Also:
-
SECONDS_PER_MILLISECOND
static final double SECONDS_PER_MILLISECONDNumber of seconds in 1 milliseconds.- See Also:
-
SECONDS_PER_MINUTE
static final double SECONDS_PER_MINUTENumber of seconds in 1 minute.- See Also:
-
SECONDS_PER_HOUR
static final double SECONDS_PER_HOURNumber of seconds in 1 hour.- See Also:
-
SECONDS_PER_DAY
static final double SECONDS_PER_DAYNumber of seconds in 1 day.- See Also:
-
SECONDS_PER_WEEK
static final double SECONDS_PER_WEEKNumber of seconds in 1 week.- See Also:
-
SECONDS_PER_MONTH
static final double SECONDS_PER_MONTHNumber of seconds in 1 month.- See Also:
-
SECONDS_PER_YEAR
static final double SECONDS_PER_YEARNumber of seconds in 1 year.- See Also:
-
SECONDS_PER_CENTURY
static final double SECONDS_PER_CENTURYNumber of seconds in 1 century.- See Also:
-
-
Constructor Details
-
TimeConverter
private TimeConverter()Constructor. Prevents instantiation of helper class.
-
-
Method Details
-
convert
Converts a time to provided output time unit.- Parameters:
input- input time to be converted.output- output time where result will be stored and containing output unit.
-
convertAndReturnNew
Converts a time to requested output unit.- Parameters:
input- input time to be converted.outputUnit- requested output unit.- Returns:
- converted time.
-
convert
Converts and updates a time to requested output unit.- Parameters:
time- input time to be converted and updated.outputUnit- requested output unit.
-
convert
Converts a time to requested output unit.- Parameters:
input- input time to be converted.outputUnit- requested output unit.result- time unit where result will be stored.
-
convert
Converts a time value from input unit to provided output unit.- Parameters:
input- time value.inputUnit- input time unit.outputUnit- output time unit.- Returns:
- converted time value.
-
convert
Converts a time value from input unit to provided output unit.- Parameters:
input- time value.inputUnit- input time unit.outputUnit- output time unit.- Returns:
- converted time value.
-
secondToNanosecond
public static double secondToNanosecond(double second) Converts provided second value to nanoseconds.- Parameters:
second- second value.- Returns:
- same amount of time converted to nanoseconds.
-
nanosecondToSecond
public static double nanosecondToSecond(double nanosecond) Converts provided nanosecond value to seconds.- Parameters:
nanosecond- nanosecond value.- Returns:
- same amount of time converted to seconds.
-
secondToMicrosecond
public static double secondToMicrosecond(double second) Converts provided second value to microseconds.- Parameters:
second- second value.- Returns:
- same amount of time converted to microseconds.
-
microsecondToSecond
public static double microsecondToSecond(double microsecond) Converts provided microsecond value to seconds.- Parameters:
microsecond- microsecond value.- Returns:
- same amount of time converted to seconds.
-
secondToMillisecond
public static double secondToMillisecond(double second) Converts provided second value to milliseconds.- Parameters:
second- second value.- Returns:
- same amount of time converted to milliseconds.
-
millisecondToSecond
public static double millisecondToSecond(double millisecond) Converts provided millisecond value to seconds.- Parameters:
millisecond- millisecond value.- Returns:
- same amount of time converted to seconds.
-
secondToMinute
public static double secondToMinute(double second) Converts provided second value to minutes.- Parameters:
second- second value.- Returns:
- same amount of time converted to minutes.
-
minuteToSecond
public static double minuteToSecond(double minute) Converts provided minute value to seconds.- Parameters:
minute- minute value.- Returns:
- same amount of time converted to seconds.
-
secondToHour
public static double secondToHour(double second) Converts provided second value to hours.- Parameters:
second- second value.- Returns:
- same amount of time converted to hours.
-
hourToSecond
public static double hourToSecond(double hour) Converts provided hour value to seconds.- Parameters:
hour- hour value.- Returns:
- same amount of time converted to seconds.
-
secondToDay
public static double secondToDay(double second) Converts provided second value to days.- Parameters:
second- second value.- Returns:
- same amount of time converted to days.
-
dayToSecond
public static double dayToSecond(double day) Converts provided day value to seconds.- Parameters:
day- day value.- Returns:
- same amount of time converted to seconds.
-
secondToWeek
public static double secondToWeek(double second) Converts provided second value to weeks.- Parameters:
second- second value.- Returns:
- same amount of time converted to weeks.
-
weekToSecond
public static double weekToSecond(double week) Converts provided week value to seconds.- Parameters:
week- week value.- Returns:
- same amount of time converted to seconds.
-
secondToMonth
public static double secondToMonth(double second) Converts provided second value to months.- Parameters:
second- second value.- Returns:
- same amount of time converted to months.
-
monthToSecond
public static double monthToSecond(double month) Converts provided month value to seconds.- Parameters:
month- month value.- Returns:
- same amount of time converted to seconds.
-
secondToYear
public static double secondToYear(double second) Converts provided second value to years.- Parameters:
second- second value.- Returns:
- same amount of time converted to years.
-
yearToSecond
public static double yearToSecond(double year) Converts provided year value to seconds.- Parameters:
year- year value.- Returns:
- same amount of time converted to seconds.
-
secondToCentury
public static double secondToCentury(double second) Converts provided second value to century.- Parameters:
second- second value.- Returns:
- same amount of time converted to centuries.
-
centuryToSecond
public static double centuryToSecond(double century) Converts provided century value to seconds.- Parameters:
century- century value.- Returns:
- same amount of time converted to seconds.
-