Modules

Module java_time_utils

kruutteri1/java_time_utils

1.0.3

Overview This module provides a Ballerina wrapper around Java's java.time package for working with dates and times that have no time zone: LocalDate, LocalDateTime, and LocalTime.

A LocalDate represents a date without a time-of-day or time-zone component, such as 2026-07-15. A LocalTime represents a time of day without a date or time zone, such as 10:15:30. A LocalDateTime combines the two into a single value, such as 2026-07-15T14:28:19.

This module does not carry any time-zone information — use ballerina/time if your use case needs to reason about time zones, UTC offsets, or daylight saving.

Installation [[dependency]] org = "kruutteri1" name = "java_time_utils" version = "1.0.3" import kruutteri1/java_time_utils.javatime as jt; Functions ofDate function ofDate(int year, int month, int day) returns LocalDate Creates a LocalDate from a year, month, and day. Panics if the day is not valid for the given month/year (e.g. February 30th).

jt:LocalDate date = jt:ofDate(2026, 7, 15); Parameters year int - The year month int - The month (1–12) day int - The day of month (1–31) Return Type LocalDate - The constructed date

ofEpochDay function ofEpochDay(int epochDay) returns LocalDate Creates a LocalDate from a day count relative to the epoch of 1970-01-01.

jt:LocalDate date = jt:ofEpochDay(0); Parameters epochDay int - The number of days since 1970-01-01 (may be negative) Return Type LocalDate - The constructed date

ofYearDay function ofYearDay(int year, int dayOfYear) returns LocalDate Creates a LocalDate from a year and a day-of-year value. Panics if dayOfYear exceeds the length of the given year.

jt:LocalDate date = jt:ofYearDay(2026, 200); Parameters year int - The year dayOfYear int - The day of year (1–365 or 1–366) Return Type LocalDate - The constructed date

getCurrentDate function getCurrentDate() returns LocalDate Returns the current date from the system clock in the default time zone.

jt:LocalDate today = jt:getCurrentDate(); Return Type LocalDate - The current date

getMINDate function getMINDate() returns LocalDate Returns the minimum supported LocalDate (-999999999-01-01).

jt:LocalDate min = jt:getMINDate(); Return Type LocalDate - The minimum date

getMAXDate function getMAXDate() returns LocalDate Returns the maximum supported LocalDate (+999999999-12-31).

jt:LocalDate max = jt:getMAXDate(); Return Type LocalDate - The maximum date

getEPOCHDate function getEPOCHDate() returns LocalDate Returns the Unix epoch date (1970-01-01).

jt:LocalDate epoch = jt:getEPOCHDate(); Return Type LocalDate - The epoch date

ofDateTime function ofDateTime(int year, int month, int dayOfMonth, int hour, int minute) returns LocalDateTime Creates a LocalDateTime from a year, month, day, hour, and minute. Panics if any component is invalid.

jt:LocalDateTime dateTime = jt:ofDateTime(2026, 7, 15, 14, 28); Parameters year int - The year month int - The month (1–12) dayOfMonth int - The day of month (1–31) hour int - The hour (0–23) minute int - The minute (0–59) Return Type LocalDateTime - The constructed date-time

ofWithSeconds function ofWithSeconds(int year, int month, int dayOfMonth, int hour, int minute, int second) returns LocalDateTime Creates a LocalDateTime including a seconds component.

jt:LocalDateTime dateTime = jt:ofWithSeconds(2026, 7, 15, 14, 28, 19); Parameters year int - The year month int - The month (1–12) dayOfMonth int - The day of month (1–31) hour int - The hour (0–23) minute int - The minute (0–59) second int - The second (0–59) Return Type LocalDateTime - The constructed date-time

ofWithNanos function ofWithNanos(int year, int month, int dayOfMonth, int hour, int minute, int second, int nanoOfSecond) returns LocalDateTime Creates a LocalDateTime including seconds and nanoseconds components.

jt:LocalDateTime dateTime = jt:ofWithNanos(2026, 7, 15, 14, 28, 19, 500000000); Parameters year int - The year month int - The month (1–12) dayOfMonth int - The day of month (1–31) hour int - The hour (0–23) minute int - The minute (0–59) second int - The second (0–59) nanoOfSecond int - The nanosecond (0–999,999,999) Return Type LocalDateTime - The constructed date-time

ofLocalDateWithLocalTime function ofLocalDateWithLocalTime(LocalDate date, LocalTime time) returns LocalDateTime Creates a LocalDateTime by combining an already-constructed LocalDate and LocalTime. Never panics, since both inputs are already validated values.

jt:LocalDate date = jt:ofDate(2026, 7, 15); jt:LocalTime time = jt:ofTime(14, 28); jt:LocalDateTime dateTime = jt:ofLocalDateWithLocalTime(date, time); Parameters date LocalDate - The date component time LocalTime - The time component Return Type LocalDateTime - The combined date-time

getCurrentDateTime function getCurrentDateTime() returns LocalDateTime Returns the current date-time from the system clock in the default time zone.

jt:LocalDateTime now = jt:getCurrentDateTime(); Return Type LocalDateTime - The current date-time

getMINDateTime function getMINDateTime() returns LocalDateTime Returns the minimum supported LocalDateTime (-999999999-01-01T00:00:00).

jt:LocalDateTime min = jt:getMINDateTime(); Return Type LocalDateTime - The minimum date-time

getMAXDateTime function getMAXDateTime() returns LocalDateTime Returns the maximum supported LocalDateTime (+999999999-12-31T23:59:59.999999999).

jt:LocalDateTime max = jt:getMAXDateTime(); Return Type LocalDateTime - The maximum date-time

ofTime function ofTime(int hour, int minute) returns LocalTime Creates a LocalTime from an hour and minute. Panics if either is out of range.

jt:LocalTime time = jt:ofTime(10, 15); Parameters hour int - The hour (0–23) minute int - The minute (0–59) Return Type LocalTime - The constructed time

ofTimeWithSecond function ofTimeWithSecond(int hour, int minute, int second) returns LocalTime Creates a LocalTime including a seconds component.

jt:LocalTime time = jt:ofTimeWithSecond(10, 15, 30); Parameters hour int - The hour (0–23) minute int - The minute (0–59) second int - The second (0–59) Return Type LocalTime - The constructed time

ofTimeWithSecondNano function ofTimeWithSecondNano(int hour, int minute, int second, int nanoOfSecond) returns LocalTime Creates a LocalTime including seconds and nanoseconds components.

jt:LocalTime time = jt:ofTimeWithSecondNano(10, 15, 30, 500000000); Parameters hour int - The hour (0–23) minute int - The minute (0–59) second int - The second (0–59) nanoOfSecond int - The nanosecond (0–999,999,999) Return Type LocalTime - The constructed time

ofNanoOfDay function ofNanoOfDay(int nanoOfDay) returns LocalTime Creates a LocalTime from a nanosecond-of-day value.

jt:LocalTime time = jt:ofNanoOfDay(0); Parameters nanoOfDay int - The number of nanoseconds since the start of the day (0 – 86,399,999,999,999) Return Type LocalTime - The constructed time

ofSecondOfDay function ofSecondOfDay(int secondOfDay) returns LocalTime Creates a LocalTime from a second-of-day value.

jt:LocalTime time = jt:ofSecondOfDay(3600); Parameters secondOfDay int - The number of seconds since the start of the day (0–86,399) Return Type LocalTime - The constructed time

getCurrentTime function getCurrentTime() returns LocalTime Returns the current time from the system clock in the default time zone.

jt:LocalTime timeNow = jt:getCurrentTime(); Return Type LocalTime - The current time

getMinTime function getMinTime() returns LocalTime Returns the minimum supported LocalTime (00:00).

jt:LocalTime min = jt:getMinTime(); Return Type LocalTime - The minimum time

getMAXTime function getMAXTime() returns LocalTime Returns the maximum supported LocalTime (23:59:59.999999999).

jt:LocalTime max = jt:getMAXTime(); Return Type LocalTime - The maximum time

getMIDNIGHT function getMIDNIGHT() returns LocalTime Returns the time of midnight (00:00).

jt:LocalTime midnight = jt:getMIDNIGHT(); Return Type LocalTime - The LocalTime for midnight

getNOON function getNOON() returns LocalTime Returns the time of noon (12:00).

jt:LocalTime noon = jt:getNOON(); Return Type LocalTime - The LocalTime for noon

Classes jt: LocalDate A date without a time-of-day or time-zone component, such as 2026-07-15.

toString function toString() returns string Returns the ISO-8601 string representation of the date.

string s = date.toString(); // "2026-07-15" Return Type string - The string form of the date

getYear function getYear() returns int Returns the year.

int year = date.getYear(); Return Type int - The year

getMonthValue function getMonthValue() returns int Returns the month-of-year as a number.

int month = date.getMonthValue(); Return Type int - The month (1–12)

getDayOfMonth function getDayOfMonth() returns int Returns the day-of-month.

int day = date.getDayOfMonth(); Return Type int - The day of month (1–31)

getDayOfYear function getDayOfYear() returns int Returns the day-of-year.

int day = date.getDayOfYear(); Return Type int - The day of year (1–365/366)

isEquals function isEquals(Object other) returns boolean Checks whether this date is equal to another object. Returns false rather than panicking if other is not a LocalDate.

boolean same = date1.isEquals(date2); Parameters other Object - The object to compare against Return Type boolean - True if equal, false otherwise

hashCode function hashCode() returns int Returns the hash code for this date, consistent with isEquals.

int h = date.hashCode(); Return Type int - The hash code

isLeapYear function isLeapYear() returns boolean Checks whether the year of this date is a leap year.

boolean leap = date.isLeapYear(); Return Type boolean - True if the year is a leap year

lengthOfMonth function lengthOfMonth() returns int Returns the number of days in the month of this date.

int days = date.lengthOfMonth(); Return Type int - The number of days in the month

lengthOfYear function lengthOfYear() returns int Returns the number of days in the year of this date (365 or 366).

int days = date.lengthOfYear(); Return Type int - The number of days in the year

toEpochDay function toEpochDay() returns int Returns the number of days since the epoch of 1970-01-01. Useful for quickly comparing dates or computing the difference in days between two dates.

int epochDay = date.toEpochDay(); Return Type int - The epoch day count

atStartOfDay function atStartOfDay() returns LocalDateTime Combines this date with the start of the day (00:00).

jt:LocalDateTime dateTime = date.atStartOfDay(); Return Type LocalDateTime - This date at midnight

atTime function atTime(int hour, int minute) returns LocalDateTime Combines this date with an hour and minute.

jt:LocalDateTime dateTime = date.atTime(14, 28); Parameters hour int - The hour (0–23) minute int - The minute (0–59) Return Type LocalDateTime - This date combined with the given time

atTimeDetailed function atTimeDetailed(int hour, int minute, int second) returns LocalDateTime Combines this date with an hour, minute, and second.

jt:LocalDateTime dateTime = date.atTimeDetailed(14, 28, 19); Parameters hour int - The hour (0–23) minute int - The minute (0–59) second int - The second (0–59) Return Type LocalDateTime - This date combined with the given time

atTimeFull function atTimeFull(int hour, int minute, int second, int nano) returns LocalDateTime Combines this date with an hour, minute, second, and nanosecond.

jt:LocalDateTime dateTime = date.atTimeFull(14, 28, 19, 500000000); Parameters hour int - The hour (0–23) minute int - The minute (0–59) second int - The second (0–59) nano int - The nanosecond (0–999,999,999) Return Type LocalDateTime - This date combined with the given time

atLocalTime function atLocalTime(LocalTime time) returns LocalDateTime Combines this date with an already-constructed LocalTime. Never panics, since time is already a validated value.

jt:LocalDateTime dateTime = date.atLocalTime(time); Parameters time LocalTime - The time to combine with this date Return Type LocalDateTime - This date combined with the given time

datesUntil function datesUntil(LocalDate endExclusive) returns Stream Returns every date from this date up to (not including) endExclusive.

Parameters endExclusive LocalDate - The end date, exclusive Return Type Stream - A stream of dates

plusYears function plusYears(int years) returns LocalDate Returns a copy of this date with the given number of years added. Does not modify the original.

jt:LocalDate next = date.plusYears(1); Parameters years int - The number of years to add Return Type LocalDate - The resulting date

plusMonths function plusMonths(int months) returns LocalDate Returns a copy of this date with the given number of months added. Clamps the day-of-month on overflow (e.g. Jan 31 + 1 month → Feb 28/29) rather than panicking.

jt:LocalDate next = date.plusMonths(1); Parameters months int - The number of months to add Return Type LocalDate - The resulting date

plusWeeks function plusWeeks(int weeks) returns LocalDate Returns a copy of this date with the given number of weeks added.

jt:LocalDate next = date.plusWeeks(1); Parameters weeks int - The number of weeks to add Return Type LocalDate - The resulting date

plusDays function plusDays(int days) returns LocalDate Returns a copy of this date with the given number of days added.

jt:LocalDate next = date.plusDays(1); Parameters days int - The number of days to add Return Type LocalDate - The resulting date

minusYears function minusYears(int years) returns LocalDate Returns a copy of this date with the given number of years subtracted.

jt:LocalDate prev = date.minusYears(1); Parameters years int - The number of years to subtract Return Type LocalDate - The resulting date

minusMonths function minusMonths(int months) returns LocalDate Returns a copy of this date with the given number of months subtracted. Clamps the day-of-month on overflow rather than panicking.

jt:LocalDate prev = date.minusMonths(1); Parameters months int - The number of months to subtract Return Type LocalDate - The resulting date

minusWeeks function minusWeeks(int weeks) returns LocalDate Returns a copy of this date with the given number of weeks subtracted.

jt:LocalDate prev = date.minusWeeks(1); Parameters weeks int - The number of weeks to subtract Return Type LocalDate - The resulting date

minusDays function minusDays(int days) returns LocalDate Returns a copy of this date with the given number of days subtracted.

jt:LocalDate prev = date.minusDays(1); Parameters days int - The number of days to subtract Return Type LocalDate - The resulting date

withYear function withYear(int year) returns LocalDate Returns a copy of this date with the year altered. Panics if the resulting date is invalid.

jt:LocalDate changed = date.withYear(2030); Parameters year int - The year to set Return Type LocalDate - The resulting date

withMonth function withMonth(int month) returns LocalDate Returns a copy of this date with the month-of-year altered. Panics if the resulting date is invalid.

jt:LocalDate changed = date.withMonth(1); Parameters month int - The month to set (1–12) Return Type LocalDate - The resulting date

withDayOfMonth function withDayOfMonth(int dayOfMonth) returns LocalDate Returns a copy of this date with the day-of-month altered. Panics if the resulting date is invalid (e.g. withDayOfMonth(30) in February).

jt:LocalDate changed = date.withDayOfMonth(1); Parameters dayOfMonth int - The day of month to set (1–31) Return Type LocalDate - The resulting date

withDayOfYear function withDayOfYear(int dayOfYear) returns LocalDate Returns a copy of this date with the day-of-year altered. Panics if the resulting date is invalid.

jt:LocalDate changed = date.withDayOfYear(200); Parameters dayOfYear int - The day of year to set (1–365/366) Return Type LocalDate - The resulting date

notify function notify() Wakes a single thread that is waiting on this object's monitor.

notifyAll function notifyAll() Wakes all threads that are waiting on this object's monitor.

doWait function doWait() returns InterruptedException? Waits for a notification on this object's monitor.

jt:InterruptedException? err = date.doWait(); Return Type InterruptedException? - An error if the thread is interrupted while waiting, or () on success

waitWithTimeout function waitWithTimeout(int timeoutMillis) returns InterruptedException? Waits for a notification, with a millisecond timeout.

Parameters timeoutMillis int - The maximum time to wait, in milliseconds Return Type InterruptedException? - An error if interrupted, or () on success/timeout

waitWithTimeoutAndNanos function waitWithTimeoutAndNanos(int timeoutMillis, int nanos) returns InterruptedException? Waits for a notification, with a timeout expressed in milliseconds and additional nanoseconds.

Parameters timeoutMillis int - The maximum time to wait, in milliseconds nanos int - Additional nanoseconds to wait Return Type InterruptedException? - An error if interrupted, or () on success/timeout

jt: LocalDateTime A date and time without a time-zone component, such as 2026-07-15T14:28:19.

toString function toString() returns string Returns the ISO-8601 string representation of the date-time.

string s = dateTime.toString(); // "2026-07-15T14:28:19" Return Type string - The string form of the date-time

getYear function getYear() returns int Returns the year. Return Type int - The year

getMonthValue function getMonthValue() returns int Returns the month-of-year as a number. Return Type int - The month (1–12)

getDayOfMonth function getDayOfMonth() returns int Returns the day-of-month. Return Type int - The day of month (1–31)

getDayOfYear function getDayOfYear() returns int Returns the day-of-year. Return Type int - The day of year (1–365/366)

getHour function getHour() returns int Returns the hour-of-day. Return Type int - The hour (0–23)

getMinute function getMinute() returns int Returns the minute-of-hour. Return Type int - The minute (0–59)

getSecond function getSecond() returns int Returns the second-of-minute. Return Type int - The second (0–59)

getNano function getNano() returns int Returns the nano-of-second. Return Type int - The nanosecond (0–999,999,999)

isEquals function isEquals(Object other) returns boolean Checks whether this date-time is equal to another object. Returns false rather than panicking if other is not a LocalDateTime.

boolean same = dateTime1.isEquals(dateTime2); Parameters other Object - The object to compare against Return Type boolean - True if equal, false otherwise

hashCode function hashCode() returns int Returns the hash code for this date-time, consistent with isEquals. Return Type int - The hash code

toLocalDate function toLocalDate() returns LocalDate Extracts the date part of this date-time.

jt:LocalDate date = dateTime.toLocalDate(); Return Type LocalDate - The date component, without the time

toLocalTime function toLocalTime() returns LocalTime Extracts the time part of this date-time.

jt:LocalTime time = dateTime.toLocalTime(); Return Type LocalTime - The time component, without the date

plusYears function plusYears(int years) returns LocalDateTime Returns a copy with the given number of years added. Parameters years int - The number of years to add Return Type LocalDateTime - The resulting date-time

plusMonths function plusMonths(int months) returns LocalDateTime Returns a copy with the given number of months added. Clamps the day-of-month on overflow rather than panicking. Parameters months int - The number of months to add Return Type LocalDateTime - The resulting date-time

plusWeeks function plusWeeks(int weeks) returns LocalDateTime Returns a copy with the given number of weeks added. Parameters weeks int - The number of weeks to add Return Type LocalDateTime - The resulting date-time

plusDays function plusDays(int days) returns LocalDateTime Returns a copy with the given number of days added. Parameters days int - The number of days to add Return Type LocalDateTime - The resulting date-time

plusHours function plusHours(int hours) returns LocalDateTime Returns a copy with the given number of hours added. Unlike LocalTime, rolling over midnight advances the calendar date rather than wrapping within the same day.

jt:LocalDateTime nearMidnight = jt:ofWithSeconds(2026, 7, 15, 23, 30, 0); jt:LocalDateTime rolledOver = nearMidnight.plusHours(1); // 2026-07-16T00:30 Parameters hours int - The number of hours to add Return Type LocalDateTime - The resulting date-time

plusMinutes function plusMinutes(int minutes) returns LocalDateTime Returns a copy with the given number of minutes added. Parameters minutes int - The number of minutes to add Return Type LocalDateTime - The resulting date-time

plusSeconds function plusSeconds(int seconds) returns LocalDateTime Returns a copy with the given number of seconds added. Parameters seconds int - The number of seconds to add Return Type LocalDateTime - The resulting date-time

plusNanos function plusNanos(int nanos) returns LocalDateTime Returns a copy with the given number of nanoseconds added. Parameters nanos int - The number of nanoseconds to add Return Type LocalDateTime - The resulting date-time

minusYears function minusYears(int years) returns LocalDateTime Returns a copy with the given number of years subtracted. Parameters years int - The number of years to subtract Return Type LocalDateTime - The resulting date-time

minusMonths function minusMonths(int months) returns LocalDateTime Returns a copy with the given number of months subtracted. Clamps the day-of-month on overflow rather than panicking. Parameters months int - The number of months to subtract Return Type LocalDateTime - The resulting date-time

minusWeeks function minusWeeks(int weeks) returns LocalDateTime Returns a copy with the given number of weeks subtracted. Parameters weeks int - The number of weeks to subtract Return Type LocalDateTime - The resulting date-time

minusDays function minusDays(int days) returns LocalDateTime Returns a copy with the given number of days subtracted. Parameters days int - The number of days to subtract Return Type LocalDateTime - The resulting date-time

minusHours function minusHours(int hours) returns LocalDateTime Returns a copy with the given number of hours subtracted. Rolling back past midnight moves to the previous calendar date. Parameters hours int - The number of hours to subtract Return Type LocalDateTime - The resulting date-time

minusMinutes function minusMinutes(int minutes) returns LocalDateTime Returns a copy with the given number of minutes subtracted. Parameters minutes int - The number of minutes to subtract Return Type LocalDateTime - The resulting date-time

minusSeconds function minusSeconds(int seconds) returns LocalDateTime Returns a copy with the given number of seconds subtracted. Parameters seconds int - The number of seconds to subtract Return Type LocalDateTime - The resulting date-time

minusNanos function minusNanos(int nanos) returns LocalDateTime Returns a copy with the given number of nanoseconds subtracted. Parameters nanos int - The number of nanoseconds to subtract Return Type LocalDateTime - The resulting date-time

withYear function withYear(int year) returns LocalDateTime Returns a copy with the year altered. Panics if the resulting date-time is invalid. Parameters year int - The year to set Return Type LocalDateTime - The resulting date-time

withMonth function withMonth(int month) returns LocalDateTime Returns a copy with the month altered. Panics if the resulting date-time is invalid. Parameters month int - The month to set (1–12) Return Type LocalDateTime - The resulting date-time

withDayOfMonth function withDayOfMonth(int dayOfMonth) returns LocalDateTime Returns a copy with the day-of-month altered. Panics if the resulting date-time is invalid. Parameters dayOfMonth int - The day of month to set (1–31) Return Type LocalDateTime - The resulting date-time

withDayOfYear function withDayOfYear(int dayOfYear) returns LocalDateTime Returns a copy with the day-of-year altered. Panics if the resulting date-time is invalid. Parameters dayOfYear int - The day of year to set (1–365/366) Return Type LocalDateTime - The resulting date-time

withHour function withHour(int hour) returns LocalDateTime Returns a copy with the hour altered. Panics if out of range. Parameters hour int - The hour to set (0–23) Return Type LocalDateTime - The resulting date-time

withMinute function withMinute(int minute) returns LocalDateTime Returns a copy with the minute altered. Panics if out of range. Parameters minute int - The minute to set (0–59) Return Type LocalDateTime - The resulting date-time

withSecond function withSecond(int second) returns LocalDateTime Returns a copy with the second altered. Panics if out of range. Parameters second int - The second to set (0–59) Return Type LocalDateTime - The resulting date-time

withNano function withNano(int nano) returns LocalDateTime Returns a copy with the nano-of-second altered. Panics if out of range. Parameters nano int - The nanosecond to set (0–999,999,999) Return Type LocalDateTime - The resulting date-time

notify function notify() Wakes a single thread waiting on this object's monitor.

notifyAll function notifyAll() Wakes all threads waiting on this object's monitor.

doWait function doWait() returns InterruptedException? Waits for a notification on this object's monitor. Return Type InterruptedException? - An error if interrupted, or () on success

waitWithTimeout function waitWithTimeout(int timeoutMillis) returns InterruptedException? Waits for a notification, with a millisecond timeout. Parameters timeoutMillis int - The maximum time to wait, in milliseconds Return Type InterruptedException? - An error if interrupted, or () on success/timeout

waitWithTimeoutAndNanos function waitWithTimeoutAndNanos(int timeoutMillis, int nanos) returns InterruptedException? Waits for a notification, with a timeout in milliseconds plus additional nanoseconds. Parameters timeoutMillis int - The maximum time to wait, in milliseconds nanos int - Additional nanoseconds to wait Return Type InterruptedException? - An error if interrupted, or () on success/timeout

jt: LocalTime A time of day without a date or time-zone component, such as 10:15:30. LocalTime is a value-based type — identity operators (==) are unreliable; use isEquals, compareTo, isAfter, or isBefore to compare values.

toString function toString() returns string Returns the ISO-8601 string representation of the time.

string s = time.toString(); // "10:15:30" Return Type string - The string form of the time

getHour function getHour() returns int Returns the hour-of-day. Return Type int - The hour (0–23)

getMinute function getMinute() returns int Returns the minute-of-hour. Return Type int - The minute (0–59)

getSecond function getSecond() returns int Returns the second-of-minute. Return Type int - The second (0–59)

getNano function getNano() returns int Returns the nano-of-second. Return Type int - The nanosecond (0–999,999,999)

isEquals function isEquals(Object other) returns boolean Checks whether this time is equal to another object. Returns false rather than panicking if other is not a LocalTime.

boolean same = time1.isEquals(time2); Parameters other Object - The object to compare against Return Type boolean - True if equal, false otherwise

compareTo function compareTo(LocalTime other) returns int Compares this time to another time.

int cmp = time1.compareTo(time2); Parameters other LocalTime - The time to compare against Return Type int - Negative, zero, or positive if this time is before, equal to, or after other

isAfter function isAfter(LocalTime other) returns boolean Checks whether this time is after the given time.

boolean later = time1.isAfter(time2); Parameters other LocalTime - The time to compare against Return Type boolean - True if this time is after other

isBefore function isBefore(LocalTime other) returns boolean Checks whether this time is before the given time.

boolean earlier = time1.isBefore(time2); Parameters other LocalTime - The time to compare against Return Type boolean - True if this time is before other

hashCode function hashCode() returns int Returns the hash code for this time, consistent with isEquals. Return Type int - The hash code

atDate function atDate(LocalDate date) returns LocalDateTime Combines this time with a date, producing a LocalDateTime. Never panics, since date is already a validated value.

jt:LocalDateTime dateTime = time.atDate(date); Parameters date LocalDate - The date to combine with this time Return Type LocalDateTime - The combined date-time

toSecondOfDay function toSecondOfDay() returns int Represents this time as a count of seconds since the start of the day.

int secOfDay = time.toSecondOfDay(); Return Type int - The number of seconds since midnight

toNanoOfDay function toNanoOfDay() returns int Represents this time as a count of nanoseconds since the start of the day.

int nanoOfDay = time.toNanoOfDay(); Return Type int - The number of nanoseconds since midnight

plusHours function plusHours(int hours) returns LocalTime Returns a copy with the given number of hours added. Wraps cyclically within the same day rather than panicking or advancing the date — e.g. 23:00 + 2 hours = 01:00. Parameters hours int - The number of hours to add Return Type LocalTime - The resulting time

plusMinutes function plusMinutes(int minutes) returns LocalTime Returns a copy with the given number of minutes added. Wraps cyclically within the same day. Parameters minutes int - The number of minutes to add Return Type LocalTime - The resulting time

plusSeconds function plusSeconds(int seconds) returns LocalTime Returns a copy with the given number of seconds added. Wraps cyclically within the same day. Parameters seconds int - The number of seconds to add Return Type LocalTime - The resulting time

plusNanos function plusNanos(int nanos) returns LocalTime Returns a copy with the given number of nanoseconds added. Wraps cyclically within the same day. Parameters nanos int - The number of nanoseconds to add Return Type LocalTime - The resulting time

minusHours function minusHours(int hours) returns LocalTime Returns a copy with the given number of hours subtracted. Wraps cyclically within the same day. Parameters hours int - The number of hours to subtract Return Type LocalTime - The resulting time

minusMinutes function minusMinutes(int minutes) returns LocalTime Returns a copy with the given number of minutes subtracted. Wraps cyclically within the same day. Parameters minutes int - The number of minutes to subtract Return Type LocalTime - The resulting time

minusSeconds function minusSeconds(int seconds) returns LocalTime Returns a copy with the given number of seconds subtracted. Wraps cyclically within the same day. Parameters seconds int - The number of seconds to subtract Return Type LocalTime - The resulting time

minusNanos function minusNanos(int nanos) returns LocalTime Returns a copy with the given number of nanoseconds subtracted. Wraps cyclically within the same day. Parameters nanos int - The number of nanoseconds to subtract Return Type LocalTime - The resulting time

withHour function withHour(int hour) returns LocalTime Returns a copy with the hour altered. Panics if out of range, instead of wrapping. Parameters hour int - The hour to set (0–23) Return Type LocalTime - The resulting time

withMinute function withMinute(int minute) returns LocalTime Returns a copy with the minute altered. Panics if out of range. Parameters minute int - The minute to set (0–59) Return Type LocalTime - The resulting time

withSecond function withSecond(int second) returns LocalTime Returns a copy with the second altered. Panics if out of range. Parameters second int - The second to set (0–59) Return Type LocalTime - The resulting time

withNano function withNano(int nano) returns LocalTime Returns a copy with the nano-of-second altered. Panics if out of range. Parameters nano int - The nanosecond to set (0–999,999,999) Return Type LocalTime - The resulting time

notify function notify() Wakes a single thread waiting on this object's monitor.

notifyAll function notifyAll() Wakes all threads waiting on this object's monitor.

doWait function doWait() returns InterruptedException? Waits for a notification on this object's monitor. Return Type InterruptedException? - An error if interrupted, or () on success

waitWithTimeout function waitWithTimeout(int timeoutMillis) returns InterruptedException? Waits for a notification, with a millisecond timeout. Parameters timeoutMillis int - The maximum time to wait, in milliseconds Return Type InterruptedException? - An error if interrupted, or () on success/timeout

waitWithTimeoutAndNanos function waitWithTimeoutAndNanos(int timeoutMillis, int nanos) returns InterruptedException? Waits for a notification, with a timeout in milliseconds plus additional nanoseconds. Parameters timeoutMillis int - The maximum time to wait, in milliseconds nanos int - Additional nanoseconds to wait Return Type InterruptedException? - An error if interrupted, or () on success/timeout

Errors jt: InterruptedException Distinct Error Returned by doWait, waitWithTimeout, and waitWithTimeoutAndNanos when the waiting thread is interrupted before being notified or timing out.

Import

import kruutteri1/java_time_utils;Copy

Other versions

Metadata

Released date: 1 day ago

Version: 1.0.3

License: Apache-2.0


Compatibility

Platform: java21

Ballerina version: 2201.13.4

GraalVM compatible: Yes


Pull count

Total: 2

Current verison: 0


Weekly downloads


Source repository


Keywords

java-time

date

time

localdate

localdatetime

localtime


Contributors