A time without a time-zone in the ISO-8601 calendar system, such as 10:30:05.

LocalTime is an immutable date-time object that represents a time, often viewed as hour-minute-second. Time is represented to nanosecond precision. For example, the value “13:45.30.123456789” can be stored in a LocalTime.

Members

Number

day

Gets the second component of the time represented by the current instance, a number from 0 to 59.

Number

hour

Gets the hour component of the time represented by the current instance, a number from 0 to 23.

Number

minute

Gets the minute component of the time represented by the current instance, a number from 0 to 59.

Number

nanosecond

Gets the nanoseconds component of the time represented by the current instance, a number from 0 to 999999999.

Constructor

new

LocalTime

(Long totalNanoseconds)

Creates a new instance of LocalTime.

Parameters:
Name Type Description
totalNanoseconds Long

Total nanoseconds since midnight.

Methods

compare

(LocalTime other)

Compares this LocalTime with the given one.

Parameters:
Name Type Description
other LocalTime

time to compare against.

Returns:
Type Description
number

0 if they are the same, 1 if the this is greater, and -1 if the given one is greater.

equals

(LocalTime other)

Returns true if the value of the LocalTime instance and other are the same

Parameters:
Name Type Description
other LocalTime
Returns:
Type Description
Boolean

LocalTime.fromBuffer

(Buffer value)

Creates a new instance of LocalTime from the bytes representation.

Static
This function is static
Parameters:
Name Type Description
value Buffer
Returns:
Type Description
LocalTime

LocalTime.fromDate

(Date date, [Number nanoseconds])

Uses the provided local time (in milliseconds) and the nanoseconds to create a new instance of LocalTime

Static
This function is static
Parameters:
Name Type Description
date Date

Local date portion to extract the time passed since midnight.

nanoseconds optional Number

A Number from 0 to 999,999, representing the nanosecond time portion.

Returns:
Type Description
LocalTime

LocalTime.fromMilliseconds

(Number milliseconds, [Number nanoseconds])

Uses the provided local time (in milliseconds) and the nanoseconds to create a new instance of LocalTime

Static
This function is static
Parameters:
Name Type Description
milliseconds Number

A Number from 0 to 86,399,999.

nanoseconds optional Number

A Number from 0 to 999,999, representing the time nanosecond portion.

Returns:
Type Description
LocalTime

LocalTime.fromString

(String value)

Parses an string representation and returns a new LocalDate.

Static
This function is static
Parameters:
Name Type Description
value String
Returns:
Type Description
LocalTime

getTotalNanoseconds

()

Gets the total amount of nanoseconds since midnight for this instance.

Returns:
Type Description
Long

LocalTime.now

([Number nanoseconds])

Uses the current local time (in milliseconds) and the nanoseconds to create a new instance of LocalTime

Static
This function is static
Parameters:
Name Type Description
nanoseconds optional Number

A Number from 0 to 999,999, representing the time nanosecond portion.

Returns:
Type Description
LocalTime

toBuffer

()

Returns a big-endian bytes representation of the instance

Returns:
Type Description
Buffer

toJSON

()

Gets the string representation of the instance in the form: hh:MM:ss.ns

Returns:
Type Description
String

toString

()

Returns the string representation of the instance in the form of hh:MM:ss.ns

Returns:
Type Description
String