java_time_utils
Module java_time_utils
API
Declarations
Definitions
kruutteri1/java_time_utils
Overview
A Ballerina wrapper around java.time — LocalDate, LocalDateTime, LocalTime, ZonedDateTime, Instant, ZoneId, ZoneOffset, ZoneRules, and other core helper and enum classes like Month and DayOfWeek for working with dates, times, time zones, and temporal components.
java.time is the gold standard for date and time handling on the JVM. java_time_utils brings that same power into Ballerina — precise date/time arithmetic, instant tracking, zone-aware operations, immutable values, and predictable behavior, all in one library, whether or not your use case involves time zones.
Installation
# Ballerina.toml [[dependency]] org = "kruutteri1" name = "java_time_utils" version = "1.1.2" # ⚠️ check central.ballerina.io for the latest version
import kruutteri1/java_time_utils as jt;
Quick Start
import ballerina/io; import kruutteri1/java_time_utils as jt; public function main() returns error? { jt:LocalDate date = check jt:ofDate(2026, 7, 15); jt:LocalTime time = check jt:ofTimeWithSecond(14, 28, 19); jt:LocalDateTime dateTime = check jt:ofLocalDateWithLocalTime(date, time); io:println(date.toString()); // 2026-07-15 io:println(time.toString()); // 14:28:19 io:println(dateTime.toString()); // 2026-07-15T14:28:19 }
Getting the Current Date and Time Without Zone
import ballerina/io; import kruutteri1/java_time_utils as jt; public function main() { jt:LocalDate today = jt:getCurrentDate(); jt:LocalTime now = jt:getCurrentTime(); jt:LocalDateTime currentDateTime = jt:getCurrentDateTime(); io:println("Today: ", today.toString()); // Today: 2026-07-22 io:println("Now: ", now.toString()); // Now: 14:57:30 io:println("Current date-time: ", currentDateTime.toString()); // Current date-time: 2026-07-22T14:57:30 }
Features
- 📅 LocalDate — dates without time or time zone
- 🗓️ LocalDateTime — dates with time, no time zone
- 🕒 LocalTime — time of day without date or time zone
- ⏳ Duration — time-based amount of time (e.g., seconds, nanoseconds)
- ⏳ Period — date-based amount of time (e.g., years, months, days)
- 📅 Month — month-of-year enum representation (such as January, July)
- 📅 DayOfWeek — day-of-week enum representation (such as Monday, Sunday)
- 🕒 DateTimeFormatter — formatting and parsing for temporal objects
- ⏱️ Instant — specific point on the time-line, measured in seconds and nanoseconds from the Unix epoch
- 🌍 ZonedDateTime — date-time with a full time-zone (region + offset), zone-aware arithmetic and conversions
- 🌐 ZoneId — time-zone identifiers (such as "Europe/Kyiv"), including system default and legacy short IDs
- ➕➖ ZoneOffset — fixed offset from UTC (such as "+02:00"), with dedicated
UTC,MIN, andMAXconstants - 🌐 ZoneRules — rules defining how a time-zone offset changes over time, including daylight savings transitions
- Robust error handling using check patterns to prevent runtime panics on invalid interop calls
- Immutable API — every
plus*,minus*, andwith*method returns a new object - Familiar
java.timesemantics, ported to idiomatic Ballerina
Functions
between
function between(LocalDateTime|LocalTime|Instant|ZonedDateTime startInclusive, LocalDateTime|LocalTime|Instant|ZonedDateTime endExclusive) returns Duration|errorObtains a Duration representing the duration between two temporal objects.
Both arguments must represent a compatible kind of time. Two values of the same type
(for example, two LocalDateTimes) always work. Mixing an absolute type (Instant,
ZonedDateTime) with another absolute type also works, since both carry enough
information (an instant, or a local date-time plus zone) to be compared directly.
Mixing an absolute type with a zone-less type (LocalDateTime, LocalTime) will result
in an error, since there's no way to know which time-zone the zone-less value refers to —
in that case, first attach an explicit zone using .atZone(zone). LocalDate is not
supported at all, since a duration in hours/minutes/seconds has no meaning for a value
with no time component — use betweenPeriod for date-only differences instead.
Parameters
- startInclusive LocalDateTime|LocalTime|Instant|ZonedDateTime - The start time object (inclusive), not null
- endExclusive LocalDateTime|LocalTime|Instant|ZonedDateTime - The end time object (exclusive), not null
betweenPeriod
Obtains a Period consisting of the number of years, months, and days between two dates.
Parameters
- startDateInclusive LocalDate - The start date, inclusive.
- endDateExclusive LocalDate - The end date, exclusive.
Return Type
- Period - The period between the start and end dates.
charSequenceCompare
Compares two char sequences lexicographically, the same way String.compareTo would.
createObject
function createObject() returns ObjectCreates a new instance of java.lang.Object.
Return Type
- Object - A new Object instance.
getApril
function getApril() returns MonthRetrieves the constant representing the month of April.
Return Type
- Month - The April month constant.
getAugust
function getAugust() returns MonthRetrieves the constant representing the month of August.
Return Type
- Month - The August month constant.
getBasicIsoDateFormatter
function getBasicIsoDateFormatter() returns DateTimeFormatterObtains the BASIC_ISO_DATE formatter that formats or parses a basic date without separators, such as "20260722".
Return Type
- DateTimeFormatter - The constructed DateTimeFormatter instance.
getCurrentDate
function getCurrentDate() returns LocalDateObtains the current date from the system clock in the default time-zone.
Return Type
- LocalDate - The current LocalDate.
getCurrentDateTime
function getCurrentDateTime() returns LocalDateTimeObtains the current date-time from the system clock in the default time-zone.
Return Type
- LocalDateTime - The current LocalDateTime.
getCurrentTime
function getCurrentTime() returns LocalTimeObtains the current time from the system clock in the default time-zone.
Return Type
- LocalTime - The current time.
getDecember
function getDecember() returns MonthRetrieves the constant representing the month of December.
Return Type
- Month - The December month constant.
getEpoch
function getEpoch() returns InstantGets the constant for the epoch of 1970-01-01T00:00:00Z.
Return Type
- Instant - The instant constant for the epoch, not null
getEpochDate
function getEpochDate() returns LocalDateReturns the epoch date (1970-01-01).
Return Type
- LocalDate - The EPOCH constant.
getFebruary
function getFebruary() returns MonthRetrieves the constant representing the month of February.
Return Type
- Month - The February month constant.
getFriday
function getFriday() returns DayOfWeekReturns the constant for Friday.
Return Type
- DayOfWeek - The FRIDAY constant.
getIsoDateFormatter
function getIsoDateFormatter() returns DateTimeFormatterObtains the ISO_DATE formatter that formats or parses a date with or without an offset, such as "2026-07-22" or "2026-07-22+03:00".
Return Type
- DateTimeFormatter - The constructed DateTimeFormatter instance.
getIsoDateTimeFormatter
function getIsoDateTimeFormatter() returns DateTimeFormatterObtains the ISO_DATE_TIME formatter that formats or parses a date-time with a zone, such as "2026-07-22T14:28:19+03:00[Europe/Kyiv]".
Return Type
- DateTimeFormatter - The constructed DateTimeFormatter instance.
getIsoInstantFormatter
function getIsoInstantFormatter() returns DateTimeFormatterObtains the ISO_INSTANT formatter that formats or parses an instant in UTC, such as "2026-07-22T11:28:19Z".
Return Type
- DateTimeFormatter - The constructed DateTimeFormatter instance.
getIsoLocalDateFormatter
function getIsoLocalDateFormatter() returns DateTimeFormatterObtains the ISO_LOCAL_DATE formatter that formats or parses a date without an offset, such as "2026-07-22".
Return Type
- DateTimeFormatter - The constructed DateTimeFormatter instance.
getIsoLocalDateTimeFormatter
function getIsoLocalDateTimeFormatter() returns DateTimeFormatterObtains the ISO_LOCAL_DATE_TIME formatter that formats or parses a date-time without an offset, such as "2026-07-22T14:28:19".
Return Type
- DateTimeFormatter - The constructed DateTimeFormatter instance.
getIsoLocalTimeFormatter
function getIsoLocalTimeFormatter() returns DateTimeFormatterObtains the ISO_LOCAL_TIME formatter that formats or parses a time without an offset, such as "14:28:19".
Return Type
- DateTimeFormatter - The constructed DateTimeFormatter instance.
getIsoOffsetDateFormatter
function getIsoOffsetDateFormatter() returns DateTimeFormatterObtains the ISO_OFFSET_DATE formatter that formats or parses a date with an offset, such as "2026-07-22+03:00".
Return Type
- DateTimeFormatter - The constructed DateTimeFormatter instance.
getIsoOffsetDateTimeFormatter
function getIsoOffsetDateTimeFormatter() returns DateTimeFormatterObtains the ISO_OFFSET_DATE_TIME formatter that formats or parses a date-time with an offset, such as "2026-07-22T14:28:19+03:00".
Return Type
- DateTimeFormatter - The constructed DateTimeFormatter instance.
getIsoOffsetTimeFormatter
function getIsoOffsetTimeFormatter() returns DateTimeFormatterObtains the ISO_OFFSET_TIME formatter that formats or parses a time with an offset, such as "14:28:19+03:00".
Return Type
- DateTimeFormatter - The constructed DateTimeFormatter instance.
getIsoOrdinalDateFormatter
function getIsoOrdinalDateFormatter() returns DateTimeFormatterObtains the ISO_ORDINAL_DATE formatter that formats or parses the ordinal date, such as "2026-203".
Return Type
- DateTimeFormatter - The constructed DateTimeFormatter instance.
getIsoTimeFormatter
function getIsoTimeFormatter() returns DateTimeFormatterObtains the ISO_TIME formatter that formats or parses a time with or without an offset, such as "14:28:19" or "14:28:19+03:00".
Return Type
- DateTimeFormatter - The constructed DateTimeFormatter instance.
getIsoWeekDateFormatter
function getIsoWeekDateFormatter() returns DateTimeFormatterObtains the ISO_WEEK_DATE formatter that formats or parses the week-based date, such as "2026-W30-3".
Return Type
- DateTimeFormatter - The constructed DateTimeFormatter instance.
getIsoZonedDateTimeFormatter
function getIsoZonedDateTimeFormatter() returns DateTimeFormatterObtains the ISO_ZONED_DATE_TIME formatter that formats or parses a date-time with a zone ID, such as "2026-07-22T14:28:19+03:00[Europe/Kyiv]".
Return Type
- DateTimeFormatter - The constructed DateTimeFormatter instance.
getJanuary
function getJanuary() returns MonthRetrieves the constant representing the month of January.
Return Type
- Month - The January month constant.
getJuly
function getJuly() returns MonthRetrieves the constant representing the month of July.
Return Type
- Month - The July month constant.
getJune
function getJune() returns MonthRetrieves the constant representing the month of June.
Return Type
- Month - The June month constant.
getMarch
function getMarch() returns MonthRetrieves the constant representing the month of March.
Return Type
- Month - The March month constant.
getMax
function getMax() returns InstantGets the constant for the latest supported instant, "1000000000-12-31T23:59:59.999999999Z".
Return Type
- Instant - The maximum supported instant, not null
getMaxDate
function getMaxDate() returns LocalDateReturns the maximum supported LocalDate (year 999999999-12-31).
Return Type
- LocalDate - The MAX constant.
getMaxDateTime
function getMaxDateTime() returns LocalDateTimeRetrieves the maximum supported LocalDateTime (+999999999-12-31T23:59:59.999999999).
Return Type
- LocalDateTime - The maximum LocalDateTime.
getMaxTime
function getMaxTime() returns LocalTimeRetrieves the value of the public field MAX.
Return Type
- LocalTime - The
LocalTimevalue of the field.
getMay
function getMay() returns MonthRetrieves the constant representing the month of May.
Return Type
- Month - The May month constant.
getMidnight
function getMidnight() returns LocalTimeRetrieves the value of the public field MIDNIGHT.
Return Type
- LocalTime - The
LocalTimevalue of the field.
getMin
function getMin() returns InstantGets the constant for the earliest supported instant, "-1000000000-01-01T00:00Z".
Return Type
- Instant - The minimum supported instant, not null
getMinDate
function getMinDate() returns LocalDateReturns the minimum supported LocalDate (year -999999999-01-01).
Return Type
- LocalDate - The MIN constant.
getMinDateTime
function getMinDateTime() returns LocalDateTimeRetrieves the minimum supported LocalDateTime (-999999999-01-01T00:00:00).
Return Type
- LocalDateTime - The minimum LocalDateTime.
getMinTime
function getMinTime() returns LocalTimeRetrieves the value of the public field MIN.
Return Type
- LocalTime - The
LocalTimevalue of the field.
getMonday
function getMonday() returns DayOfWeekReturns the constant for Monday.
Return Type
- DayOfWeek - The MONDAY constant.
getMonthValues
Returns an array containing the constants of this enum class, in the order they're declared.
getNoon
function getNoon() returns LocalTimeRetrieves the value of the public field NOON.
Return Type
- LocalTime - The
LocalTimevalue of the field.
getNovember
function getNovember() returns MonthRetrieves the constant representing the month of November.
Return Type
- Month - The November month constant.
getOctober
function getOctober() returns MonthRetrieves the constant representing the month of October.
Return Type
- Month - The October month constant.
getRfc1123DateTimeFormatter
function getRfc1123DateTimeFormatter() returns DateTimeFormatterObtains the RFC_1123_DATE_TIME formatter that formats or parses a date-time according to RFC 1123, such as "Wed, 22 Jul 2026 14:28:19 +0300".
Return Type
- DateTimeFormatter - The constructed DateTimeFormatter instance.
getSaturday
function getSaturday() returns DayOfWeekReturns the constant for Saturday.
Return Type
- DayOfWeek - The SATURDAY constant.
getSeptember
function getSeptember() returns MonthRetrieves the constant representing the month of September.
Return Type
- Month - The September month constant.
getSunday
function getSunday() returns DayOfWeekReturns the constant for Sunday.
Return Type
- DayOfWeek - The SUNDAY constant.
getThursday
function getThursday() returns DayOfWeekReturns the constant for Thursday.
Return Type
- DayOfWeek - The THURSDAY constant.
getTuesday
function getTuesday() returns DayOfWeekReturns the constant for Tuesday.
Return Type
- DayOfWeek - The TUESDAY constant.
getUtc
function getUtc() returns ZoneOffsetGets the constant for the UTC zone offset (an offset of zero).
Return Type
- ZoneOffset - The zone offset constant for UTC, not null
getWednesday
function getWednesday() returns DayOfWeekReturns the constant for Wednesday.
Return Type
- DayOfWeek - The WEDNESDAY constant.
getWeekValues
Returns all seven DayOfWeek constants, in declaration order (MONDAY first).
getZERO
function getZERO() returns DurationObtains a constant Duration instance representing a zero length.
Return Type
- Duration - The
ZEROduration instance.
getZero
function getZero() returns PeriodRetrieves the constant for a period of zero.
Return Type
- Period - A period of zero.
instantNow
function instantNow() returns InstantObtains the current instant from the system clock.
Return Type
- Instant - The current instant using the system clock, not null
instantOfEpochMilli
Obtains an instance of Instant using milliseconds from the epoch of 1970-01-01T00:00:00Z.
Parameters
- epochMilli int - The number of milliseconds from 1970-01-01T00:00:00Z
Return Type
- Instant - The instant, not null
instantOfEpochSecond
Obtains an instance of Instant using seconds from the epoch of 1970-01-01T00:00:00Z.
Parameters
- epochSecond int - The number of seconds from 1970-01-01T00:00:00Z
Return Type
- Instant - The instant, not null
instantOfEpochSecondWithNanoAdjustment
function instantOfEpochSecondWithNanoAdjustment(int epochSecond, int nanoAdjustment) returns Instant|errorObtains an instance of Instant using seconds from the epoch, with an additional nanosecond adjustment that may exceed the range 0-999,999,999 and will be normalized accordingly.
monthOf
Obtains an instance of Month from an int value.
Parameters
- month int - The month-of-year to represent, from 1 (January) to 12 (December).
nowFromZone
Obtains the current time from the system clock in the specified time-zone.
Parameters
- zone ZoneId - The time-zone to use.
Return Type
- LocalTime - The current time.
nowWithZone
function nowWithZone(ZoneId zone) returns LocalDateTimeObtains the current date-time from the system clock in the specified time-zone.
Parameters
- zone ZoneId - The time-zone to use.
Return Type
- LocalDateTime - The current LocalDateTime.
ofDate
Obtains a LocalDate from a year, month, and day.
ofDateTime
function ofDateTime(int year, int month, int dayOfMonth, int hour, int minute) returns LocalDateTime|errorObtains an instance of LocalDateTime from year, month, day, hour, and minute.
Parameters
- year int - The year to represent.
- month int - The month-of-year to represent (1-12).
- dayOfMonth int - The day-of-month to represent (1-31).
- hour int - The hour-of-day to represent (0-23).
- minute int - The minute-of-hour to represent (0-59).
Return Type
- LocalDateTime|error - LocalDateTime|error — the constructed date-time, or an error if the date-time is invalid.
ofDateWithMonth
Obtains a LocalDate from a year, month, and day.
ofDay
Creates a DayOfWeek from an ISO-8601 numeric value.
Parameters
- dayOfWeek int - The day-of-week value, from 1 (MONDAY) to 7 (SUNDAY).
ofDays
Obtains a Duration representing a number of standard 24-hour days.
Parameters
- days int - The number of days, positive or negative.
Return Type
- Duration - The created
Durationinstance.
ofDayValue
Returns the DayOfWeek constant with the specified name (e.g. "MONDAY").
Parameters
- name string - The name of the constant to return.
ofEnumValue
Returns the enum constant of the specified enum type with the specified name.
ofEpochDay
Obtains a LocalDate from the epoch day count.
Parameters
- epochDay int - The number of days from the epoch of 1970-01-01.
ofEpochSecond
function ofEpochSecond(int epochSecond, int nanoOfSecond, ZoneOffset offset) returns LocalDateTime|errorObtains an instance of LocalDateTime using seconds from the epoch of 1970-01-01T00:00:00Z.
Parameters
- epochSecond int - The number of seconds from the epoch.
- nanoOfSecond int - The nanosecond within the second.
- offset ZoneOffset - The zone offset.
Return Type
- LocalDateTime|error - The LocalDateTime.
ofHours
Obtains a Duration representing a number of hours.
Parameters
- hours int - The number of hours, positive or negative.
Return Type
- Duration - The created
Durationinstance.
ofInstant
Obtains a LocalDate from an Instant and a time-zone.
Return Type
- LocalDate - The LocalDate.
ofInstantWithZone
function ofInstantWithZone(Instant instant, ZoneId zone) returns LocalDateTimeObtains an instance of LocalDateTime from an Instant and ZoneId.
Return Type
- LocalDateTime - The LocalDateTime.
ofInstantWithZones
Obtains an instance of LocalTime from an Instant and ZoneId.
Return Type
- LocalTime - The LocalTime.
ofLocalDateWithLocalTime
function ofLocalDateWithLocalTime(LocalDate date, LocalTime time) returns LocalDateTimeObtains an instance of LocalDateTime from a LocalDate and LocalTime.
Return Type
- LocalDateTime - The LocalDateTime.
ofLocalizedPattern
function ofLocalizedPattern(string text) returns DateTimeFormatter|errorCreates a formatter using the specified pattern template, such as "dd.MM.yyyy".
Parameters
- text string - The pattern template to use, such as "dd.MM.yyyy".
Return Type
- DateTimeFormatter|error - The constructed DateTimeFormatter instance.
ofMillis
Obtains a Duration representing a number of milliseconds.
Parameters
- millis int - The number of milliseconds, positive or negative.
Return Type
- Duration - The created
Durationinstance.
ofMinutes
Obtains a Duration representing a number of minutes.
Parameters
- minutes int - The number of minutes, positive or negative.
Return Type
- Duration - The created
Durationinstance.
ofMonthFull
function ofMonthFull(int year, Month month, int dayOfMonth, int hour, int minute) returns LocalDateTime|errorObtains an instance of LocalDateTime from year, Month enum, day, hour, and minute.
Parameters
- year int - The year to represent.
- month Month - The Month enum.
- dayOfMonth int - The day-of-month to represent (1-31).
- hour int - The hour-of-day to represent (0-23).
- minute int - The minute-of-hour to represent (0-59).
Return Type
- LocalDateTime|error - LocalDateTime|error — the constructed date-time, or an error if the date-time is invalid.
ofMonthFullWithNano
function ofMonthFullWithNano(int year, Month month, int dayOfMonth, int hour, int minute, int second, int nanoOfSecond) returns LocalDateTime|errorObtains an instance of LocalDateTime from year, Month enum, day, hour, minute, second, and nanosecond.
Parameters
- year int - The year to represent.
- month Month - The Month enum.
- dayOfMonth int - The day-of-month to represent (1-31).
- hour int - The hour-of-day to represent (0-23).
- minute int - The minute-of-hour to represent (0-59).
- second int - The second-of-minute to represent (0-59).
- nanoOfSecond int - The nano-of-second to represent (0-999,999,999).
Return Type
- LocalDateTime|error - LocalDateTime|error — the constructed date-time, or an error if the date-time is invalid.
ofMonthFullWithsecond
function ofMonthFullWithsecond(int year, Month month, int dayOfMonth, int hour, int minute, int second) returns LocalDateTime|errorObtains an instance of LocalDateTime from year, Month enum, day, hour, minute, and second.
Parameters
- year int - The year to represent.
- month Month - The Month enum.
- dayOfMonth int - The day-of-month to represent (1-31).
- hour int - The hour-of-day to represent (0-23).
- minute int - The minute-of-hour to represent (0-59).
- second int - The second-of-minute to represent (0-59).
Return Type
- LocalDateTime|error - LocalDateTime|error — the constructed date-time, or an error if the date-time is invalid.
ofMonthValue
Returns the enum constant of this type with the specified name.
Parameters
- name string - The name of the constant to return.
ofNanoOfDay
Obtains an instance of LocalTime from a nanos-of-day value.
Parameters
- nanoOfDay int - The nanos of day.
ofNanos
Obtains a Duration representing a number of nanoseconds.
Parameters
- nanos int - The number of nanoseconds, positive or negative.
Return Type
- Duration - The created
Durationinstance.
ofPattern
function ofPattern(string pattern) returns DateTimeFormatter|errorCreates a formatter using the specified pattern, such as "yyyy-MM-dd HH:mm:ss", "yyyy.MM.dd 'at' HH:mm:ss".
Parameters
- pattern string - The pattern to use, such as "yyyy-MM-dd HH:mm:ss".
Return Type
- DateTimeFormatter|error - The constructed DateTimeFormatter instance, or an error if the pattern is invalid.
ofPeriod
Obtains a Period representing a number of years, months, and days.
Parameters
- years int - The amount of years, may be negative.
- months int - The amount of months, may be negative.
- days int - The amount of days, may be negative.
Return Type
- Period - The period of years, months and days.
ofPeriodDays
Obtains a Period representing a number of days.
Parameters
- days int - The number of days, may be negative.
Return Type
- Period - A period with the specified number of days.
ofPeriodMonths
Obtains a Period representing a number of months.
Parameters
- months int - The number of months, may be negative.
Return Type
- Period - A period with the specified number of months.
ofPeriodWeeks
Obtains a Period representing a number of weeks.
Parameters
- weeks int - The number of weeks, may be negative.
Return Type
- Period - A period with the specified number of weeks.
ofPeriodYears
Obtains a Period representing a number of years.
Parameters
- years int - The number of years, may be negative.
Return Type
- Period - A period with the specified number of years.
ofSecondOfDay
Obtains an instance of LocalTime from a second-of-day value.
Parameters
- secondOfDay int - The second of day.
ofSeconds
Obtains a Duration representing a number of seconds.
Parameters
- seconds int - The number of seconds, positive or negative.
Return Type
- Duration - The created
Durationinstance.
ofSecondsWithNanos
Obtains a Duration representing a number of seconds and an adjustment in nanoseconds.
ofTime
Obtains an instance of LocalTime from an hour and minute.
ofTimeWithSecond
Obtains an instance of LocalTime from an hour, minute and second.
ofTimeWithSecondNano
function ofTimeWithSecondNano(int hour, int minute, int second, int nanoOfSecond) returns LocalTime|errorObtains an instance of LocalTime from an hour, minute, second and nanosecond.
ofWithNanos
function ofWithNanos(int year, int month, int dayOfMonth, int hour, int minute, int second, int nanoOfSecond) returns LocalDateTime|errorObtains an instance of LocalDateTime from year, month, day, hour, minute, second, and nanosecond.
Parameters
- year int - The year to represent.
- month int - The month-of-year to represent (1-12).
- dayOfMonth int - The day-of-month to represent (1-31).
- hour int - The hour-of-day to represent (0-23).
- minute int - The minute-of-hour to represent (0-59).
- second int - The second-of-minute to represent (0-59).
- nanoOfSecond int - The nano-of-second to represent (0-999,999,999).
Return Type
- LocalDateTime|error - LocalDateTime|error — the constructed date-time, or an error if the date-time is invalid.
ofWithSeconds
function ofWithSeconds(int year, int month, int dayOfMonth, int hour, int minute, int second) returns LocalDateTime|errorObtains an instance of LocalDateTime from year, month, day, hour, minute, and second.
Parameters
- year int - The year to represent.
- month int - The month-of-year to represent (1-12).
- dayOfMonth int - The day-of-month to represent (1-31).
- hour int - The hour-of-day to represent (0-23).
- minute int - The minute-of-hour to represent (0-59).
- second int - The second-of-minute to represent (0-59).
Return Type
- LocalDateTime|error - LocalDateTime|error — the constructed date-time, or an error if the date-time is invalid.
ofYearDay
Obtains a LocalDate from a year and day-of-year.
parseDate
Parses a string to a LocalDate using the ISO-8601 formatter.
Parameters
- text string - The text to parse, such as "2026-07-15".
parseDateFormat
function parseDateFormat(string text, DateTimeFormatter formatter) returns LocalDate|errorParses a string to a LocalDate using a specific formatter.
parseDateTime
function parseDateTime(string text) returns LocalDateTime|errorParses a text string to a LocalDateTime using the default ISO_LOCAL_DATE_TIME formatter, such as "2026-07-22T14:28:19".
Parameters
- text string - The text to parse.
Return Type
- LocalDateTime|error - LocalDateTime|error — the constructed date-time, or an error if the date-time is invalid.
parseDateTimeFormat
function parseDateTimeFormat(string text, DateTimeFormatter formatter) returns LocalDateTime|errorParses a text string to a LocalDateTime using a specific formatter.
Return Type
- LocalDateTime|error - LocalDateTime|error — the constructed date-time, or an error if the date-time is invalid.
parseDuration
Obtains a Duration from a text string such as PT20.345S (ISO-8601 format).
Parameters
- text string - The text string to parse, not null.
parseInstant
Obtains an instance of Instant from a text string such as "2007-12-03T10:15:30.00Z".
Parameters
- text string - The text to parse, not null
parsePeriod
Obtains a Period from a text string such as PnYnMnD.
Parameters
- text string - The text to parse, not null.
parseTime
Obtains an instance of LocalTime from a text string, such as "14:28:19".
Parameters
- text string - The text to parse.
parseTimeFormat
function parseTimeFormat(string text, DateTimeFormatter formatter) returns LocalTime|errorObtains an instance of LocalTime from a text string using a specific formatter.
parseZonedDateTime
function parseZonedDateTime(string text) returns ZonedDateTime|errorObtains an instance of ZonedDateTime from a text string such as 2007-12-03T10:15:30+01:00[Europe/Paris].
Parameters
- text string - The text to parse, not null
Return Type
- ZonedDateTime|error - The parsed zoned date-time, not null
utcNow
function utcNow() returns ZonedDateTimeObtains the current date-time from the system clock in the UTC zone.
Return Type
- ZonedDateTime - The current zoned date-time in UTC, not null
withZone
Obtains the current date in the specified time-zone.
Parameters
- zone ZoneId - The time-zone to use.
Return Type
- LocalDate - The current LocalDate.
zonedDateTimeNow
function zonedDateTimeNow() returns ZonedDateTimeObtains the current date-time from the system clock in the default time-zone.
Return Type
- ZonedDateTime - The current date-time using the system clock, not null
zonedDateTimeNowByZone
function zonedDateTimeNowByZone(ZoneId zone) returns ZonedDateTimeObtains the current date-time from the system clock in the specified time-zone.
Parameters
- zone ZoneId - The zone ID to use, not null
Return Type
- ZonedDateTime - The current date-time, not null
zonedDateTimeOf
function zonedDateTimeOf(int year, int month, int dayOfMonth, int hour, int minute, int second, int nanoOfSecond, ZoneId zone) returns ZonedDateTime|errorObtains an instance of ZonedDateTime from a year, month, day, hour, minute, second, and nanosecond, with a zone.
Parameters
- year int - The year to represent, from MIN_YEAR to MAX_YEAR
- month int - The month-of-year to represent, from 1 to 12
- dayOfMonth int - The day-of-month to represent, from 1 to 31
- hour int - The hour-of-day to represent, from 0 to 23
- minute int - The minute-of-hour to represent, from 0 to 59
- second int - The second-of-minute to represent, from 0 to 59
- nanoOfSecond int - The nano-of-second to represent, from 0 to 999,999,999
- zone ZoneId - The time-zone, not null
Return Type
- ZonedDateTime|error - The zoned date-time, not null
zonedDateTimeOfDateAndTime
function zonedDateTimeOfDateAndTime(LocalDate date, LocalTime time, ZoneId zone) returns ZonedDateTimeObtains an instance of ZonedDateTime from a local date, time, and zone.
Parameters
- date LocalDate - The local date, not null
- time LocalTime - The local time, not null
- zone ZoneId - The time-zone, not null
Return Type
- ZonedDateTime - The zoned date-time, not null
zonedDateTimeOfDateTime
function zonedDateTimeOfDateTime(LocalDateTime dateTime, ZoneId zone) returns ZonedDateTimeObtains an instance of ZonedDateTime from a local date-time and zone.
Parameters
- dateTime LocalDateTime - The local date-time, not null
- zone ZoneId - The time-zone, not null
Return Type
- ZonedDateTime - The zoned date-time, not null
zonedDateTimeOfDateTimeWithOffset
function zonedDateTimeOfDateTimeWithOffset(LocalDateTime dateTime, ZoneOffset offset, ZoneId zone) returns ZonedDateTimeObtains an instance of ZonedDateTime from the local date-time, offset and zone ID.
Parameters
- dateTime LocalDateTime - The local date-time, not null
- offset ZoneOffset - The zone offset, not null
- zone ZoneId - The time-zone, not null
Return Type
- ZonedDateTime - The zoned date-time, not null
zonedDateTimeOfInstant
function zonedDateTimeOfInstant(Instant instant, ZoneId zone) returns ZonedDateTimeObtains an instance of ZonedDateTime from an Instant and zone ID.
Parameters
- instant Instant - The instant to create the date-time from, not null
- zone ZoneId - The time-zone to use, not null
Return Type
- ZonedDateTime - The zoned date-time, not null
zonedDateTimeOfLocal
function zonedDateTimeOfLocal(LocalDateTime localDateTime, ZoneId zone, ZoneOffset preferredOffset) returns ZonedDateTimeObtains an instance of ZonedDateTime from a local date-time using the preferred zone, evaluating overlap/gap.
Parameters
- localDateTime LocalDateTime - The local date-time, not null
- zone ZoneId - The preferred time-zone, not null
- preferredOffset ZoneOffset - The zone offset, not null
Return Type
- ZonedDateTime - The zoned date-time, not null
zonedDateTimeOfStrict
function zonedDateTimeOfStrict(LocalDateTime localDateTime, ZoneOffset offset, ZoneId zone) returns ZonedDateTimeObtains an instance of ZonedDateTime strictly combining a local date-time, offset and zone ID.
Parameters
- localDateTime LocalDateTime - The local date-time, not null
- offset ZoneOffset - The zone offset, not null
- zone ZoneId - The time-zone, not null
Return Type
- ZonedDateTime - The zoned date-time, not null
zonedDateTimeParseWithFormatter
function zonedDateTimeParseWithFormatter(string text, DateTimeFormatter formatter) returns ZonedDateTime|errorObtains an instance of ZonedDateTime from a text string using a specific formatter.
Parameters
- text string - The text to parse, not null
- formatter DateTimeFormatter - The formatter to use, not null
Return Type
- ZonedDateTime|error - The parsed zoned date-time, not null
zoneIdGetAvailableZoneIds
function zoneIdGetAvailableZoneIds() returns SetGets the set of available zone IDs supported by the platform, such as "Europe/Kyiv" or "America/New_York".
Return Type
- Set - A modifiable copy of the set of zone IDs, not null
zoneIdGetShortIds
function zoneIdGetShortIds() returns MapGets the map of short zone IDs (such as "EST", "PST") to their full zone ID equivalents.
Return Type
- Map - The map of short zone IDs, not null
zoneIdOf
Obtains an instance of ZoneId from a zone ID string, such as "Europe/Paris" or "+02:00".
Parameters
- zoneId string - The time-zone ID, not null
zoneIdOfOffset
function zoneIdOfOffset(string prefix, ZoneOffset offset) returns ZoneId|errorObtains an instance of ZoneId, allowing a prefix to be combined with a zone offset, such as "GMT+02:00".
Parameters
- prefix string - The time-zone ID prefix, one of "GMT", "UTC", "UT", or an empty string
- offset ZoneOffset - The zone offset, not null
zoneIdSystemDefault
function zoneIdSystemDefault() returns ZoneIdGets the system default time-zone.
Return Type
- ZoneId - The zone ID for the system default time-zone, not null
zoneOffsetFrom
function zoneOffsetFrom(TemporalAccessor temporalAccessor) returns ZoneOffsetObtains an instance of ZoneOffset from a temporal object, such as a ZonedDateTime or OffsetDateTime.
Parameters
- temporalAccessor TemporalAccessor - The temporal object to convert, not null
Return Type
- ZoneOffset - The zone offset, not null
zoneOffsetGetMax
function zoneOffsetGetMax() returns ZoneOffsetGets the constant for the maximum supported positive zone offset, "+18:00".
Return Type
- ZoneOffset - The maximum supported zone offset, not null
zoneOffsetGetMin
function zoneOffsetGetMin() returns ZoneOffsetGets the constant for the maximum supported negative zone offset, "-18:00".
Return Type
- ZoneOffset - The minimum supported zone offset, not null
zoneOffsetOf
function zoneOffsetOf(string offsetId) returns ZoneOffset|errorObtains an instance of ZoneOffset using its offset ID, such as "+02:00", "Z", "+2" or "+02:30:15".
Parameters
- offsetId string - The offset ID, not null
Return Type
- ZoneOffset|error - The zone offset, or an error if the ID has an invalid format
zoneOffsetOfHours
function zoneOffsetOfHours(int hours) returns ZoneOffset|errorObtains an instance of ZoneOffset using an offset in hours, such as +2 for "+02:00".
Parameters
- hours int - The time-zone offset in hours, from -18 to +18
Return Type
- ZoneOffset|error - The zone offset, not null
zoneOffsetOfHoursMinutes
function zoneOffsetOfHoursMinutes(int hours, int minutes) returns ZoneOffset|errorObtains an instance of ZoneOffset using an offset in hours and minutes, such as (+2, +30) for "+02:30".
Parameters
- hours int - The time-zone offset in hours, from -18 to +18
- minutes int - The time-zone offset in minutes, from -59 to +59, having the same sign as
hours
Return Type
- ZoneOffset|error - The zone offset, not null
zoneOffsetOfHoursMinutesSeconds
function zoneOffsetOfHoursMinutesSeconds(int hours, int minutes, int seconds) returns ZoneOffset|errorObtains an instance of ZoneOffset using an offset in hours, minutes, and seconds.
Parameters
- hours int - The time-zone offset in hours, from -18 to +18
- minutes int - The time-zone offset in minutes, from -59 to +59, having the same sign as
hours
- seconds int - The time-zone offset in seconds, from -59 to +59, having the same sign as
hoursandminutes
Return Type
- ZoneOffset|error - The zone offset, not null
zoneOffsetOfTotalSeconds
function zoneOffsetOfTotalSeconds(int totalSeconds) returns ZoneOffset|errorObtains an instance of ZoneOffset from a total offset in seconds, such as +7200 for "+02:00".
Parameters
- totalSeconds int - The total time-zone offset in seconds, from -64800 to +64800
Return Type
- ZoneOffset|error - The zone offset, not null
zoneOffsetParseAsZoneId
Obtains an instance of ZoneOffset using its offset ID, resolved via ZoneOffset but returned as a ZoneId.
Despite mirroring ZoneId.of(String) in naming, this still enforces ZoneOffset's strict offset-format
parsing (such as "+02:00" or "Z") — it does NOT accept region-based zone IDs like "Europe/Kyiv".
Parameters
- offsetId string - The offset ID, not null
zoneRulesOf
function zoneRulesOf(ZoneOffset offset) returns ZoneRulesObtains an instance of ZoneRules with a fixed offset that has no daylight-saving transitions.
Parameters
- offset ZoneOffset - The offset to apply for the entire lifetime of these rules, not null
Return Type
- ZoneRules - The zone rules, not null
Classes
java_time_utils: Appendable
Ballerina class mapping for the Java java.lang.Appendable interface.
Constructor
The init function of the Ballerina class mapping the java.lang.Appendable Java interface.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.lang.Appendable Java interface.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.lang.Appendableobject.
java_time_utils: CharSequence
Ballerina class mapping for the Java java.lang.CharSequence interface.
Constructor
The init function of the Ballerina class mapping the java.lang.CharSequence Java interface.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.lang.CharSequence Java interface.
Return Type
- string - The
stringform of the Java object instance.
charAt
Gets the character (as its Unicode code point) at the specified index in this char sequence.
Parameters
- index int - The index of the character to get, from 0 to length()-1
Return Type
- int - The Unicode code point of the character at the specified index (Ballerina has no char type, so this is returned as an int rather than a single-character string)
subSequence
Returns a substring of this char sequence, from the start index (inclusive) to the end index (exclusive).
Parameters
- startIndex int - The start index, inclusive, from 0 to length()
- endIndex int - The end index, exclusive, from startIndex to length()
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.lang.CharSequenceobject.
java_time_utils: ChronoLocalDate
Ballerina class mapping for the Java java.time.chrono.ChronoLocalDate interface.
Constructor
The init function of the Ballerina class mapping the java.time.chrono.ChronoLocalDate Java interface.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.chrono.ChronoLocalDate Java interface.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.chrono.ChronoLocalDateobject.
java_time_utils: ChronoLocalDateTime
Ballerina class mapping for the Java java.time.chrono.ChronoLocalDateTime interface.
Constructor
The init function of the Ballerina class mapping the java.time.chrono.ChronoLocalDateTime Java interface.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.chrono.ChronoLocalDateTime Java interface.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.chrono.ChronoLocalDateTimeobject.
java_time_utils: Chronology
Ballerina class mapping for the Java java.time.chrono.Chronology interface.
Constructor
The init function of the Ballerina class mapping the java.time.chrono.Chronology Java interface.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.chrono.Chronology Java interface.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.chrono.Chronologyobject.
java_time_utils: ChronoZonedDateTime
Ballerina class mapping for the Java java.time.chrono.ChronoZonedDateTime interface.
Constructor
The init function of the Ballerina class mapping the java.time.chrono.ChronoZonedDateTime Java interface.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.chrono.ChronoZonedDateTime Java interface.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.chrono.ChronoZonedDateTimeobject.
java_time_utils: Class
Ballerina class mapping for the Java java.lang.Class class.
Constructor
The init function of the Ballerina class mapping the java.lang.Class Java class.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.lang.Class Java class.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.lang.Classobject.
java_time_utils: Clock
Ballerina class mapping for the Java java.time.Clock class.
Constructor
The init function of the Ballerina class mapping the java.time.Clock Java class.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.Clock Java class.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.Clockobject.
java_time_utils: DateTimeFormatter
Ballerina class mapping for the Java java.time.format.DateTimeFormatter class.
Constructor
The init function of the Ballerina class mapping the java.time.format.DateTimeFormatter Java class.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.format.DateTimeFormatter Java class.
Return Type
- string - The
stringform of the Java object instance.
isEquals
Checks if this DateTimeFormatter is equal to another object.
Parameters
- other Object - The object to compare with this
DateTimeFormatter, not null
Return Type
- boolean -
trueif the given object is equal to this formatter,falseotherwise
getClass
function getClass() returns ClassThe function that maps to the getClass method of java.time.format.DateTimeFormatter.
Return Type
- Class - The
Classvalue returning from the Java mapping.
hashCode
function hashCode() returns intThe function that maps to the hashCode method of java.time.format.DateTimeFormatter.
Return Type
- int - The
intvalue returning from the Java mapping.
notify
function notify()The function that maps to the notify method of java.time.format.DateTimeFormatter.
notifyAll
function notifyAll()The function that maps to the notifyAll method of java.time.format.DateTimeFormatter.
doWait
function doWait() returns InterruptedException?The function that maps to the wait method of java.time.format.DateTimeFormatter.
Return Type
- InterruptedException? - The
InterruptedExceptionvalue returning from the Java mapping.
waitWithTimeout
function waitWithTimeout(int arg0) returns InterruptedException?The function that maps to the wait method of java.time.format.DateTimeFormatter.
Parameters
- arg0 int - The
intvalue required to map with the Java method parameter.
Return Type
- InterruptedException? - The
InterruptedExceptionvalue returning from the Java mapping.
waitWithTimeoutAndNanos
function waitWithTimeoutAndNanos(int timeoutMillis, int nanos) returns InterruptedException?Causes the current thread to wait until it is notified or the specified
timeout elapses. Maps to the wait(long, int) method of java.lang.Object,
inherited by DateTimeFormatter.
Parameters
- timeoutMillis int - The maximum time to wait, in milliseconds
- nanos int - Additional time, in nanoseconds, in the range 0-999999
Return Type
- InterruptedException? - An
InterruptedExceptionif the current thread is interrupted while waiting, otherwise()
withZone
function withZone(ZoneId zone) returns DateTimeFormatterReturns a copy of this formatter with a new override zone. The override zone is used to convert instants to a time-zone-aware representation before formatting, when the object being formatted does not itself contain zone information (or when overriding the zone it does contain).
Parameters
- zone ZoneId - The zone to use, not null
Return Type
- DateTimeFormatter - A copy of this formatter with the specified override zone, not null
Fields
- Fields Included from *JObject
- jObj handle
- Fields Included from *Object
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.format.DateTimeFormatterobject.
java_time_utils: DayOfWeek
Ballerina class mapping for the Java java.time.DayOfWeek class.
DayOfWeek is an enum representing the seven days of the week
(MONDAY through SUNDAY). It is returned by LocalDate.getDayOfWeek()
and LocalDateTime.getDayOfWeek().
Constructor
Initializes the DayOfWeek wrapper.
init (handle obj)- obj handle - The handle value containing the Java reference.
describeConstable
function describeConstable() returns OptionalReturns an optional descriptor of this enum constant for use with
nominal descriptors (Java's Constable mechanism).
Method included from *Enum
toString
function toString() returns stringReturns the string representation of this day-of-week (e.g. "MONDAY").
Return Type
- string - The string form of the day-of-week.
compareTo
Compares this day-of-week to another enum constant by ordinal position.
Parameters
- other Enum - The enum constant to compare against.
Return Type
- int - Negative, zero, or positive if this constant is declared before, at the same position as, or after other.
isEquals
Checks whether this day-of-week is equal to another object. Returns false rather than panicking if other is not a DayOfWeek.
Parameters
- other Object - The object to compare against.
Return Type
- boolean - True if equal, false otherwise.
getClass
function getClass() returns ClassReturns the runtime class of this object.
Return Type
- Class - The Class object representing the runtime class.
getDeclaringClass
function getDeclaringClass() returns ClassReturns the Class object corresponding to this enum constant's enum type.
Return Type
- Class - The Class of the enum type.
getValue
function getValue() returns intReturns the ISO-8601 numeric value of this day-of-week.
Return Type
- int - The day-of-week value, from 1 (MONDAY) to 7 (SUNDAY).
hashCode
function hashCode() returns intReturns the hash code for this day-of-week.
Return Type
- int - The hash code.
minusDays
Returns the day-of-week that results from subtracting the specified number of days from this one, cycling through the week.
Parameters
- days int - The number of days to subtract; may be negative.
Return Type
- DayOfWeek - The resulting day-of-week.
name
function name() returns stringReturns the name of this enum constant exactly as declared (e.g. "MONDAY").
Return Type
- string - The declared name of this constant.
notify
function notify()Wakes up a single thread that is waiting on this object's monitor.
WARNING: This is a low-level Java synchronization method. Avoid using it in business logic.
notifyAll
function notifyAll()Wakes up all threads that are waiting on this object's monitor.
WARNING: This is a low-level Java synchronization method. Avoid using it in business logic.
ordinal
function ordinal() returns intReturns the position of this constant in its enum declaration, where the first constant has an ordinal of zero (MONDAY = 0, ..., SUNDAY = 6).
Return Type
- int - The ordinal of this constant.
plusDays
Returns the day-of-week that results from adding the specified number of days to this one, cycling through the week.
Parameters
- days int - The number of days to add; may be negative.
Return Type
- DayOfWeek - The resulting day-of-week.
doWait
function doWait() returns InterruptedException?Causes the current thread to wait until notified.
WARNING: Low-level Java synchronization method. Use with caution.
Return Type
- InterruptedException? - An InterruptedException if the thread is interrupted while waiting.
waitWithTimeout
function waitWithTimeout(int timeoutMillis) returns InterruptedException?Causes the current thread to wait until notified or the specified time elapses.
WARNING: Low-level Java synchronization method. Use with caution.
Parameters
- timeoutMillis int - The maximum time to wait, in milliseconds.
Return Type
- InterruptedException? - An InterruptedException if the thread is interrupted while waiting.
waitWithTimeoutAndNanos
function waitWithTimeoutAndNanos(int timeoutMillis, int nanos) returns InterruptedException?Causes the current thread to wait until notified, with the specified timeout.
WARNING: Low-level Java synchronization method. Use with caution.
Parameters
- timeoutMillis int - The maximum time to wait, in milliseconds.
- nanos int - Additional nanoseconds to wait.
Return Type
- InterruptedException? - An InterruptedException if the thread is interrupted while waiting.
Fields
- Fields Included from *JObject
- jObj handle
- Fields Included from *Enum
- jObj handle
- jObj handle - The handle to the underlying Java object.
java_time_utils: DecimalStyle
Ballerina class mapping for the Java java.time.format.DecimalStyle class.
Constructor
The init function of the Ballerina class mapping the java.time.format.DecimalStyle Java class.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.format.DecimalStyle Java class.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.format.DecimalStyleobject.
java_time_utils: Duration
Ballerina class mapping for the Java java.time.Duration class.
Constructor
Initializes the Ballerina wrapper with a Java reference.
init (handle obj)- obj handle - The
handlevalue containing the Java reference.
toString
function toString() returns stringReturns the string representation of the duration.
Return Type
- string - The string form of the duration instance.
abs
function abs() returns DurationReturns a copy of this duration with a positive length.
Return Type
- Duration - A duration with a positive length.
compareTo
Compares this duration to another duration.
Parameters
- other Duration - The other duration to compare with.
Return Type
- int - Negative, zero, or positive as this duration is less than, equal to, or greater than the other.
dividedByDuration
Divides this duration by another duration.
Parameters
- other Duration - The other duration to divide by.
Return Type
- int - The ratio of the durations as an integer.
dividedBy
Divides this duration by the specified value.
Parameters
- divisor int - The value to divide by.
Return Type
- Duration - A duration-representing the result of the division.
isEquals
Checks if this duration is equal to another object.
Parameters
- other Object - The object to check equality with.
Return Type
- boolean - True if this duration is equal to the other object, false otherwise.
getClass
function getClass() returns ClassGets the runtime class of this duration.
Return Type
- Class - The
Classobject representing the runtime class.
getNano
function getNano() returns intGets the number of nanoseconds in the second-based part of this duration.
Return Type
- int - The number of nanoseconds, from 0 to 999,999,999.
getSeconds
function getSeconds() returns intGets the number of seconds in this duration.
Return Type
- int - The whole seconds part of the duration.
getUnits
function getUnits() returns ListGets the list of units supported by this duration.
Return Type
- List - A
Listcontaining the supportedTemporalUnitinstances.
hashCode
function hashCode() returns intReturns a hash code for this duration.
Return Type
- int - A suitable hash code value.
isNegative
function isNegative() returns booleanChecks if this duration is negative, excluding zero.
Return Type
- boolean - True if this duration has a total length less than zero, false otherwise.
isPositive
function isPositive() returns booleanChecks if this duration is positive, excluding zero.
Return Type
- boolean - True if this duration has a total length greater than zero, false otherwise.
isZero
function isZero() returns booleanChecks if this duration is zero length.
Return Type
- boolean - True if this duration has a total length of zero, false otherwise.
minus
Returns a copy of this duration with the specified duration subtracted.
Parameters
- other Duration - The duration to subtract, not null.
Return Type
- Duration - A duration based on this duration with the specified duration subtracted.
minusDays
Returns a copy of this duration with the specified number of days subtracted.
Parameters
- days int - The days to subtract, positive or negative.
Return Type
- Duration - A duration based on this duration with the specified days subtracted.
minusHours
Returns a copy of this duration with the specified number of hours subtracted.
Parameters
- hours int - The hours to subtract, positive or negative.
Return Type
- Duration - A duration based on this duration with the specified hours subtracted.
minusMillis
Returns a copy of this duration with the specified number of milliseconds subtracted.
Parameters
- millis int - The milliseconds to subtract, positive or negative.
Return Type
- Duration - A duration based on this duration with the specified milliseconds subtracted.
minusMinutes
Returns a copy of this duration with the specified number of minutes subtracted.
Parameters
- minutes int - The minutes to subtract, positive or negative.
Return Type
- Duration - A duration based on this duration with the specified minutes subtracted.
minusNanos
Returns a copy of this duration with the specified number of nanoseconds subtracted.
Parameters
- nanos int - The nanoseconds to subtract, positive or negative.
Return Type
- Duration - A duration based on this duration with the specified nanoseconds subtracted.
minusSeconds
Returns a copy of this duration with the specified number of seconds subtracted.
Parameters
- seconds int - The seconds to subtract, positive or negative.
Return Type
- Duration - A duration based on this duration with the specified seconds subtracted.
multipliedBy
Returns a copy of this duration multiplied by the specified scalar.
Parameters
- multiplier int - The value to multiply by, positive or negative.
Return Type
- Duration - A duration based on this duration multiplied by the scalar.
negated
function negated() returns DurationReturns a copy of this duration with the length negated.
Return Type
- Duration - A duration based on this duration with the amount negated.
notify
function notify()Wakes up a single thread that is waiting on this object's monitor.
notifyAll
function notifyAll()Wakes up all threads that are waiting on this object's monitor.
plus
Returns a copy of this duration with the specified duration added.
Parameters
- other Duration - The duration to add, not null.
Return Type
- Duration - A duration based on this duration with the specified duration added.
plusDays
Returns a copy of this duration with the specified number of days added.
Parameters
- days int - The days to add, positive or negative.
Return Type
- Duration - A duration based on this duration with the specified days added.
plusHours
Returns a copy of this duration with the specified number of hours added.
Parameters
- hours int - The hours to add, positive or negative.
Return Type
- Duration - A duration based on this duration with the specified hours added.
plusMillis
Returns a copy of this duration with the specified number of milliseconds added.
Parameters
- millis int - The milliseconds to add, positive or negative.
Return Type
- Duration - A duration based on this duration with the specified milliseconds added.
plusMinutes
Returns a copy of this duration with the specified number of minutes added.
Parameters
- minutes int - The minutes to add, positive or negative.
Return Type
- Duration - A duration based on this duration with the specified minutes added.
plusNanos
Returns a copy of this duration with the specified number of nanoseconds added.
Parameters
- nanos int - The nanoseconds to add, positive or negative.
Return Type
- Duration - A duration based on this duration with the specified nanoseconds added.
plusSeconds
Returns a copy of this duration with the specified number of seconds added.
Parameters
- seconds int - The seconds to add, positive or negative.
Return Type
- Duration - A duration based on this duration with the specified seconds added.
toDays
function toDays() returns intGets the number of days in this duration.
Return Type
- int - The total number of days in the duration.
toDaysPart
function toDaysPart() returns intExtracts the number of days in this duration.
Return Type
- int - The number of days part, after dividing out the hours, minutes and seconds.
toHours
function toHours() returns intGets the number of hours in this duration.
Return Type
- int - The total number of hours in the duration.
toHoursPart
function toHoursPart() returns intExtracts the number of hours part in this duration.
Return Type
- int - The number of hours part, in the range 0 to 23.
toMillis
function toMillis() returns intGets the number of milliseconds in this duration.
Return Type
- int - The total number of milliseconds in the duration.
toMillisPart
function toMillisPart() returns intExtracts the number of milliseconds part in this duration.
Return Type
- int - The number of milliseconds part, in the range 0 to 999.
toMinutes
function toMinutes() returns intGets the number of minutes in this duration.
Return Type
- int - The total number of minutes in the duration.
toMinutesPart
function toMinutesPart() returns intExtracts the number of minutes part in this duration.
Return Type
- int - The number of minutes part, in the range 0 to 59.
toNanos
function toNanos() returns intGets the total number of nanoseconds in this duration.
Return Type
- int - The total number of nanoseconds in the duration.
toNanosPart
function toNanosPart() returns intExtracts the number of nanoseconds part in this duration.
Return Type
- int - The number of nanoseconds part, in the range 0 to 999,999,999.
toSeconds
function toSeconds() returns intGets the number of seconds in this duration.
Return Type
- int - The total number of seconds in the duration.
toSecondsPart
function toSecondsPart() returns intExtracts the number of seconds part in this duration.
Return Type
- int - The number of seconds part, in the range 0 to 59.
doWait
function doWait() returns InterruptedException?Causes the current thread to wait until another thread invokes the notify() or notifyAll() methods for this object.
Return Type
- InterruptedException? - An
InterruptedExceptionif the thread was interrupted while waiting, or nil otherwise.
waitWithTimeout
function waitWithTimeout(int millis) returns InterruptedException?Causes the current thread to wait until another thread invokes notify() or notifyAll() for this object, or a certain amount of real time has elapsed.
Parameters
- millis int - The maximum time to wait in milliseconds.
Return Type
- InterruptedException? - An
InterruptedExceptionif the thread was interrupted while waiting, or nil otherwise.
waitWithTimeoutAndNanos
function waitWithTimeoutAndNanos(int millis, int nanos) returns InterruptedException?Causes the current thread to wait until another thread invokes notify() or notifyAll() for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
Parameters
- millis int - The maximum time to wait in milliseconds.
- nanos int - Additional nanoseconds, in the range 0-999,999.
Return Type
- InterruptedException? - An
InterruptedExceptionif the thread was interrupted while waiting, or nil otherwise.
withNanos
Returns a copy of this duration with the specified number of nanoseconds.
Parameters
- nanos int - The number of nanoseconds to represent, from 0 to 999,999,999.
Return Type
- Duration - A duration based on this duration with the requested nanoseconds.
withSeconds
Returns a copy of this duration with the specified number of seconds.
Parameters
- seconds int - The number of seconds, positive or negative.
Return Type
- Duration - A duration based on this duration with the requested seconds.
Fields
- Fields Included from *JObject
- jObj handle
- Fields Included from *Object
- jObj handle
- jObj handle - The underlying Java object reference.
java_time_utils: Enum
Ballerina class mapping for the Java java.lang.Enum class.
Enum is the common base type for all Java enum classes. In this
library, DayOfWeek and Month both extend it, giving access to
shared enum behavior (ordinal, name, compareTo, etc.)
without duplicating it in each concrete enum wrapper.
Constructor
Initializes the Enum wrapper.
init (handle obj)- obj handle - The handle value containing the Java reference.
toString
function toString() returns stringReturns the string representation of this enum constant (its declared name).
Return Type
- string - The string form of the constant.
compareTo
Compares this enum constant to another by declaration (ordinal) order. Only meaningful when both constants belong to the same enum type.
Parameters
- other Enum - The enum constant to compare against.
Return Type
- int - Negative, zero, or positive if this constant is declared before, at the same position as, or after other.
isEquals
Checks whether this enum constant is equal to another object. Enum constants are only ever equal to themselves (reference equality), so this returns false for any object that isn't this exact constant.
Parameters
- other Object - The object to compare against.
Return Type
- boolean - True if equal, false otherwise.
getClass
function getClass() returns ClassReturns the runtime class of this object.
Return Type
- Class - The Class object representing the runtime class.
getDeclaringClass
function getDeclaringClass() returns ClassReturns the Class object corresponding to this enum constant's actual enum type (useful when the constant belongs to an enum with constant-specific method bodies).
Return Type
- Class - The Class of the enum type.
hashCode
function hashCode() returns intReturns the hash code for this enum constant.
Return Type
- int - The hash code.
name
function name() returns stringReturns the name of this enum constant exactly as declared in its enum type (e.g. "MONDAY", "JANUARY").
Return Type
- string - The declared name of this constant.
notify
function notify()Wakes up a single thread that is waiting on this object's monitor.
WARNING: This is a low-level Java synchronization method. Avoid using it in business logic.
notifyAll
function notifyAll()Wakes up all threads that are waiting on this object's monitor.
WARNING: This is a low-level Java synchronization method. Avoid using it in business logic.
ordinal
function ordinal() returns intReturns the position of this constant in its enum declaration, where the first constant has an ordinal of zero.
Return Type
- int - The ordinal of this constant.
doWait
function doWait() returns InterruptedException?Causes the current thread to wait until notified.
WARNING: Low-level Java synchronization method. Use with caution.
Return Type
- InterruptedException? - An InterruptedException if the thread is interrupted while waiting.
waitWithTimeout
function waitWithTimeout(int timeoutMillis) returns InterruptedException?Causes the current thread to wait until notified or the specified time elapses.
WARNING: Low-level Java synchronization method. Use with caution.
Parameters
- timeoutMillis int - The maximum time to wait, in milliseconds.
Return Type
- InterruptedException? - An InterruptedException if the thread is interrupted while waiting.
waitWithTimeoutAndNanos
function waitWithTimeoutAndNanos(int timeoutMillis, int nanos) returns InterruptedException?Causes the current thread to wait until notified, with the specified timeout.
WARNING: Low-level Java synchronization method. Use with caution.
Parameters
- timeoutMillis int - The maximum time to wait, in milliseconds.
- nanos int - Additional nanoseconds to wait.
Return Type
- InterruptedException? - An InterruptedException if the thread is interrupted while waiting.
Fields
- Fields Included from *JObject
- jObj handle
- Fields Included from *Object
- jObj handle
- jObj handle - The handle to the underlying Java object.
java_time_utils: Format
Ballerina class mapping for the Java java.text.Format class.
Constructor
The init function of the Ballerina class mapping the java.text.Format Java class.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.text.Format Java class.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.text.Formatobject.
java_time_utils: FormatStyle
Ballerina class mapping for the Java java.time.format.FormatStyle class.
Constructor
The init function of the Ballerina class mapping the java.time.format.FormatStyle Java class.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.format.FormatStyle Java class.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.format.FormatStyleobject.
java_time_utils: Instant
Ballerina class mapping for the Java java.time.Instant class.
Constructor
The init function of the Ballerina class mapping the java.time.Instant Java class.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringReturns the string representation of this instant, in ISO-8601 format such as "2026-07-27T11:30:00Z".
Return Type
- string - The
stringform of the Java object instance.
adjustInto
Adjusts the specified temporal object to have the same instant as this object.
Parameters
- temporal Temporal - The target temporal object to adjust, not null
Return Type
- Temporal - The adjusted temporal object, not null
atOffset
function atOffset(ZoneOffset offset) returns OffsetDateTimeCombines this instant with an offset to create an OffsetDateTime.
Parameters
- offset ZoneOffset - The offset to combine with, not null
Return Type
- OffsetDateTime - The offset date-time formed from this instant and the specified offset, not null
atZone
function atZone(ZoneId zone) returns ZonedDateTimeCombines this instant with a time-zone to create a ZonedDateTime.
Parameters
- zone ZoneId - The zone to combine with, not null
Return Type
- ZonedDateTime - The zoned date-time formed from this instant and the specified zone, not null
compareTo
Compares this instant to another instant on the time-line.
Parameters
- other Instant - The other instant to compare to, not null
Return Type
- int - A negative number if this instant is earlier, positive if later, zero if equal
isEquals
Checks whether this instant is equal to another object.
Parameters
- other Object - The object to compare with, may be
()
Return Type
- boolean -
trueif this instant is equal to the specified object
get
function get(TemporalField fieldToGet) returns intGets the value of the specified field from this instant as an int.
Parameters
- fieldToGet TemporalField - The field to query, not null
Return Type
- int - The value of the field
getClass
function getClass() returns ClassGets the runtime class of this Instant object.
Return Type
- Class - The
Classobject representing the runtime class, not null
getEpochSecond
function getEpochSecond() returns intGets the number of seconds from the epoch of 1970-01-01T00:00:00Z.
Return Type
- int - The seconds from the epoch, may be negative for instants before the epoch
getNano
function getNano() returns intGets the number of nanoseconds, later along the time-line, from the start of the second.
Return Type
- int - The nano-of-second, from 0 to 999,999,999
hashCode
function hashCode() returns intReturns a hash code value for this instant.
Return Type
- int - A suitable hash code
isAfter
Checks whether this instant is after the specified instant.
Parameters
- other Instant - The other instant to compare to, not null
Return Type
- boolean -
trueif this instant is after the specified instant
isBefore
Checks whether this instant is before the specified instant.
Parameters
- other Instant - The other instant to compare to, not null
Return Type
- boolean -
trueif this instant is before the specified instant
minusAmount
Returns a copy of this Instant with the specified amount subtracted.
Parameters
minusMillis
Returns a copy of this instant with the specified number of milliseconds subtracted.
Parameters
- millisToSubtract int - The milliseconds to subtract, may be negative
Return Type
- Instant - A copy of this instant with the specified milliseconds subtracted, not null
minusNanos
Returns a copy of this instant with the specified number of nanoseconds subtracted.
Parameters
- nanosToSubtract int - The nanoseconds to subtract, may be negative
Return Type
- Instant - A copy of this instant with the specified nanoseconds subtracted, not null
minusSeconds
Returns a copy of this instant with the specified number of seconds subtracted.
Parameters
- secondsToSubtract int - The seconds to subtract, may be negative
Return Type
- Instant - A copy of this instant with the specified seconds subtracted, not null
notify
function notify()Wakes up a single thread that is waiting on this object's monitor.
notifyAll
function notifyAll()Wakes up all threads that are waiting on this object's monitor.
plusAmount
Returns a copy of this Instant with the specified amount added.
Parameters
plusMillis
Returns a copy of this instant with the specified number of milliseconds added.
Parameters
- millisToAdd int - The milliseconds to add, may be negative
Return Type
- Instant - A copy of this instant with the specified milliseconds added, not null
plusNanos
Returns a copy of this instant with the specified number of nanoseconds added.
Parameters
- nanosToAdd int - The nanoseconds to add, may be negative
Return Type
- Instant - A copy of this instant with the specified nanoseconds added, not null
plusSeconds
Returns a copy of this instant with the specified number of seconds added.
Parameters
- secondsToAdd int - The seconds to add, may be negative
Return Type
- Instant - A copy of this instant with the specified seconds added, not null
toEpochMilli
function toEpochMilli() returns intConverts this instant to the number of milliseconds from the epoch of 1970-01-01T00:00:00Z.
Return Type
- int - The number of milliseconds since the epoch
doWait
function doWait() returns InterruptedException?Causes the current thread to wait until it is woken up on this object's monitor, typically via a call to notify() or notifyAll().
Return Type
- InterruptedException? - An
InterruptedExceptionif the waiting thread is interrupted, otherwise()
waitWithTimeout
function waitWithTimeout(int timeoutMillis) returns InterruptedException?Causes the current thread to wait until either it is woken up or the specified timeout elapses.
Parameters
- timeoutMillis int - The maximum time to wait, in milliseconds
Return Type
- InterruptedException? - An
InterruptedExceptionif the waiting thread is interrupted, otherwise()
waitWithTimeoutAndNanos
function waitWithTimeoutAndNanos(int timeoutMillis, int additionalNanos) returns InterruptedException?Causes the current thread to wait until either it is woken up or the specified timeout elapses, with additional nanosecond precision.
Parameters
- timeoutMillis int - The maximum time to wait, in milliseconds
- additionalNanos int - The additional time to wait, in nanoseconds, from 0 to 999999
Return Type
- InterruptedException? - An
InterruptedExceptionif the waiting thread is interrupted, otherwise()
Fields
- Fields Included from *JObject
- jObj handle
- Fields Included from *Object
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.Instantobject.
java_time_utils: IntStream
Ballerina class mapping for the Java java.util.stream.IntStream interface.
Constructor
The init function of the Ballerina class mapping the java.util.stream.IntStream Java interface.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.util.stream.IntStream Java interface.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.util.stream.IntStreamobject.
java_time_utils: IsoChronology
Ballerina class mapping for the Java java.time.chrono.IsoChronology class.
Constructor
The init function of the Ballerina class mapping the java.time.chrono.IsoChronology Java class.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.chrono.IsoChronology Java class.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.chrono.IsoChronologyobject.
java_time_utils: IsoEra
Ballerina class mapping for the Java java.time.chrono.IsoEra class.
Constructor
The init function of the Ballerina class mapping the java.time.chrono.IsoEra Java class.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.chrono.IsoEra Java class.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.chrono.IsoEraobject.
java_time_utils: List
Ballerina class mapping for the Java java.util.List interface.
Constructor
The init function of the Ballerina class mapping the java.util.List Java interface.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.util.List Java interface.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.util.Listobject.
java_time_utils: LocalDate
Represents a date without a time-zone in the ISO-8601 calendar system, such as 2026-07-15.
Constructor
Initializes the LocalDate wrapper.
init (handle obj)- obj handle - The handle value containing the Java reference.
toString
function toString() returns stringReturns the string representation of this date in ISO-8601 format.
Return Type
- string - The string form (e.g., "2026-07-15").
atStartOfDay
function atStartOfDay() returns LocalDateTimeReturns a LocalDateTime formed from this date at the start of the day (00:00).
Return Type
- LocalDateTime - The resulting LocalDateTime.
atTime
function atTime(int hour, int minute) returns LocalDateTimeCombines this date with the specified time to create a LocalDateTime.
Return Type
- LocalDateTime - The resulting LocalDateTime.
atTimeDetailed
function atTimeDetailed(int hour, int minute, int second) returns LocalDateTimeCombines this date with the specified time (hours, minutes, seconds) to create a LocalDateTime.
Return Type
- LocalDateTime - The resulting LocalDateTime.
atTimeFull
function atTimeFull(int hour, int minute, int second, int nano) returns LocalDateTimeCombines this date with the specified time (hours, minutes, seconds, nanos) to create a LocalDateTime.
Parameters
- hour int - The hour.
- minute int - The minute.
- second int - The second.
- nano int - The nanosecond.
Return Type
- LocalDateTime - The resulting LocalDateTime.
atLocalTime
function atLocalTime(LocalTime time) returns LocalDateTimeCombines this date with the specified LocalTime to create a LocalDateTime.
Parameters
- time LocalTime - The LocalTime to combine with this date.
Return Type
- LocalDateTime - The resulting LocalDateTime.
isEquals
Checks if this date is equal to another object.
Parameters
- other Object - The object to check equality with.
Return Type
- boolean - True if equal, false otherwise.
format
function format(DateTimeFormatter formatter) returns stringFormats this date using the specified formatter.
Parameters
- formatter DateTimeFormatter - The date-time formatter to use.
Return Type
- string - The formatted date string.
getClass
function getClass() returns ClassReturns the class of this object.
Return Type
- Class - The Java class instance.
getDayOfMonth
function getDayOfMonth() returns intReturns the day-of-month.
Return Type
- int - The day-of-month, from 1 to 31.
getDayOfWeek
function getDayOfWeek() returns DayOfWeekReturns the day-of-week.
Return Type
- DayOfWeek - The day-of-week enum.
getDayOfYear
function getDayOfYear() returns intReturns the day-of-year.
Return Type
- int - The day-of-year, from 1 to 365 or 366.
getEra
function getEra() returns IsoEraReturns the era.
Return Type
- IsoEra - The era constant.
getMonth
function getMonth() returns MonthReturns the month-of-year.
Return Type
- Month - The month enum.
getMonthValue
function getMonthValue() returns intReturns the month-of-year value (1-12).
Return Type
- int - The month-of-year.
getYear
function getYear() returns intReturns the year.
Return Type
- int - The year.
hashCode
function hashCode() returns intReturns the hash code for this date.
Return Type
- int - The hash code.
isAfter
Checks if this date is after the specified date.
Parameters
- other LocalDate - The other date to compare to, not null
Return Type
- boolean - True if this date is after the specified date
isBefore
Checks if this date is before the specified date.
Parameters
- other LocalDate - The other date to compare to, not null
Return Type
- boolean - True if this date is before the specified date
isEqual
Checks if this date is equal to the specified date.
Parameters
- other LocalDate - The other date to compare to.
Return Type
- boolean - True if this date is equal to the specified date.
isLeapYear
function isLeapYear() returns booleanChecks if the year is a leap year.
Return Type
- boolean - True if the year is a leap year.
lengthOfMonth
function lengthOfMonth() returns intReturns the length of the month represented by this date.
Return Type
- int - The length of the month.
lengthOfYear
function lengthOfYear() returns intReturns the length of the year represented by this date.
Return Type
- int - The length of the year.
minusPeriod
Returns a copy of this date with the specified period subtracted.
Parameters
- interval Period - The amount to subtract.
Return Type
- LocalDate - A date with the period subtracted.
minusDays
Returns a copy of this date with the specified number of days subtracted.
Parameters
- days int - The days to subtract.
Return Type
- LocalDate - A date with the days subtracted.
minusMonths
Returns a copy of this date with the specified number of months subtracted.
Parameters
- months int - The months to subtract.
Return Type
- LocalDate - A date with the months subtracted.
minusWeeks
Returns a copy of this date with the specified number of weeks subtracted.
Parameters
- weeks int - The number of weeks to subtract.
Return Type
- LocalDate - A new LocalDate with the weeks subtracted.
minusYears
Returns a copy of this date with the specified number of years subtracted.
Parameters
- years int - The number of years to subtract.
Return Type
- LocalDate - A new LocalDate with the years subtracted.
notify
function notify()Wakes up a single thread that is waiting on this object's monitor. WARNING: This is a low-level Java synchronization method. Avoid using it in business logic.
notifyAll
function notifyAll()Wakes up all threads that are waiting on this object's monitor. WARNING: This is a low-level Java synchronization method. Avoid using it in business logic.
plusPeriod
Returns a copy of this date with the specified period added.
Parameters
- interval Period - The amount to add.
Return Type
- LocalDate - A new LocalDate with the specified period added.
plusDays
Returns a copy of this date with the specified number of days added.
Parameters
- days int - The number of days to add, may be negative.
Return Type
- LocalDate - A new LocalDate with the days added.
plusMonths
Returns a copy of this date with the specified number of months added.
Parameters
- months int - The number of months to add, may be negative.
Return Type
- LocalDate - A new LocalDate with the months added.
plusWeeks
Returns a copy of this date with the specified number of weeks added.
Parameters
- weeks int - The number of weeks to add, may be negative.
Return Type
- LocalDate - A new LocalDate with the weeks added.
plusYears
Returns a copy of this date with the specified number of years added.
Parameters
- years int - The number of years to add, may be negative.
Return Type
- LocalDate - A new LocalDate with the years added.
toEpochDay
function toEpochDay() returns intReturns the epoch day count.
Return Type
- int - The epoch day count.
toEpochSecond
function toEpochSecond(LocalTime time, ZoneOffset offset) returns intReturns the epoch second for this date at the specified time and offset.
Return Type
- int - The epoch second.
doWait
function doWait() returns InterruptedException?Causes the current thread to wait until notified. WARNING: Low-level Java synchronization method. Use with caution.
Return Type
- InterruptedException? - An InterruptedException if the thread is interrupted while waiting.
waitWithTimeout
function waitWithTimeout(int timeoutMillis) returns InterruptedException?Causes the current thread to wait until notified or the specified time elapses. WARNING: Low-level Java synchronization method. Use with caution.
Parameters
- timeoutMillis int - The maximum time to wait in milliseconds.
Return Type
- InterruptedException? - An InterruptedException if the thread is interrupted while waiting.
waitWithTimeoutAndNanos
function waitWithTimeoutAndNanos(int timeoutMillis, int nanos) returns InterruptedException?Causes the current thread to wait until notified, with the specified timeout. WARNING: Low-level Java synchronization method. Use with caution.
Parameters
- timeoutMillis int - The maximum time to wait in milliseconds.
- nanos int - Additional nanoseconds to wait.
Return Type
- InterruptedException? - An InterruptedException if the thread is interrupted while waiting.
withDayOfMonth
Returns a copy of this date with the day-of-month altered.
Parameters
- dayOfMonth int - The day-of-month to set (1-31).
withDayOfYear
Returns a copy of this date with the day-of-year altered.
Parameters
- dayOfYear int - The day-of-year to set (1-365/366).
withMonth
Returns a copy of this date with the month-of-year altered.
Parameters
- month int - The month-of-year to set (1-12).
withYear
Returns a copy of this date with the year altered.
Parameters
- year int - The year to set.
Fields
- Fields Included from *JObject
- jObj handle
- Fields Included from *Object
- jObj handle
- jObj handle - The handle to the underlying Java object.
java_time_utils: LocalDateTime
Represents a date-time without a time-zone in the ISO-8601 calendar system, such as 2026-07-15T14:28:19.
Constructor
Initializes the LocalDateTime wrapper.
init (handle obj)- obj handle - The handle value containing the Java reference.
toString
function toString() returns stringReturns the string representation of this date-time in ISO-8601 format.
Return Type
- string - The string form (e.g., "2026-07-15T14:28:19").
isEquals
Checks if this date-time is equal to another object.
Parameters
- other Object - The object to check equality with.
Return Type
- boolean - True if equal, false otherwise.
format
function format(DateTimeFormatter formatter) returns stringFormats this date-time using the specified formatter.
Parameters
- formatter DateTimeFormatter - The date-time formatter to use.
Return Type
- string - The formatted date-time string.
getChronology
function getChronology() returns ChronologyReturns the chronology of this date-time.
Return Type
- Chronology - The ISO chronology.
getClass
function getClass() returns ClassReturns the class of this object.
Return Type
- Class - The Java class instance.
getDayOfMonth
function getDayOfMonth() returns intReturns the day-of-month.
Return Type
- int - The day-of-month, from 1 to 31.
getDayOfWeek
function getDayOfWeek() returns DayOfWeekReturns the day-of-week.
Return Type
- DayOfWeek - The day-of-week enum.
getDayOfYear
function getDayOfYear() returns intReturns the day-of-year.
Return Type
- int - The day-of-year, from 1 to 365 or 366.
getHour
function getHour() returns intReturns the hour-of-day.
Return Type
- int - The hour-of-day, from 0 to 23.
getMinute
function getMinute() returns intReturns the minute-of-hour.
Return Type
- int - The minute-of-hour, from 0 to 59.
getMonth
function getMonth() returns MonthReturns the month-of-year.
Return Type
- Month - The month enum.
getMonthValue
function getMonthValue() returns intReturns the month-of-year value (1-12).
Return Type
- int - The month-of-year.
getNano
function getNano() returns intReturns the nano-of-second.
Return Type
- int - The nano-of-second, from 0 to 999,999,999.
getSecond
function getSecond() returns intReturns the second-of-minute.
Return Type
- int - The second-of-minute, from 0 to 59.
getYear
function getYear() returns intReturns the year.
Return Type
- int - The year.
hashCode
function hashCode() returns intReturns the hash code for this date-time.
Return Type
- int - The hash code.
isAfter
function isAfter(LocalDateTime other) returns booleanChecks if this date-time is after the specified date-time.
Parameters
- other LocalDateTime - The other date-time to compare to, not null
Return Type
- boolean - True if this date-time is after the specified date-time
isBefore
function isBefore(LocalDateTime other) returns booleanChecks if this date-time is before the specified date-time.
Parameters
- other LocalDateTime - The other date-time to compare to, not null
Return Type
- boolean - True if this date-time is before the specified date-time
isEqual
function isEqual(LocalDateTime other) returns booleanChecks if this date-time is equal to the specified date-time.
Parameters
- other LocalDateTime - The other date-time to compare to.
Return Type
- boolean - True if this date-time is equal to the specified date-time.
minusInterval
function minusInterval(Period|Duration interval) returns LocalDateTimeReturns a copy of this date-time with the specified period subtracted.
Return Type
- LocalDateTime - A new LocalDateTime with the period subtracted.
minusDays
function minusDays(int days) returns LocalDateTimeReturns a copy of this date-time with the specified number of days subtracted.
Parameters
- days int - The days to subtract.
Return Type
- LocalDateTime - A new LocalDateTime with the days subtracted.
minusHours
function minusHours(int hours) returns LocalDateTimeReturns a copy of this date-time with the specified number of hours subtracted.
Parameters
- hours int - The hours to subtract.
Return Type
- LocalDateTime - A new LocalDateTime with the hours subtracted.
minusMinutes
function minusMinutes(int minutes) returns LocalDateTimeReturns a copy of this date-time with the specified number of minutes subtracted.
Parameters
- minutes int - The minutes to subtract.
Return Type
- LocalDateTime - A new LocalDateTime with the minutes subtracted.
minusMonths
function minusMonths(int months) returns LocalDateTimeReturns a copy of this date-time with the specified number of months subtracted.
Parameters
- months int - The months to subtract.
Return Type
- LocalDateTime - A new LocalDateTime with the months subtracted.
minusNanos
function minusNanos(int nanos) returns LocalDateTimeReturns a copy of this date-time with the specified number of nanoseconds subtracted.
Parameters
- nanos int - The nanoseconds to subtract.
Return Type
- LocalDateTime - A new LocalDateTime with the nanoseconds subtracted.
minusSeconds
function minusSeconds(int seconds) returns LocalDateTimeReturns a copy of this date-time with the specified number of seconds subtracted.
Parameters
- seconds int - The seconds to subtract.
Return Type
- LocalDateTime - A new LocalDateTime with the seconds subtracted.
minusWeeks
function minusWeeks(int weeks) returns LocalDateTimeReturns a copy of this date-time with the specified number of weeks subtracted.
Parameters
- weeks int - The weeks to subtract.
Return Type
- LocalDateTime - A new LocalDateTime with the weeks subtracted.
minusYears
function minusYears(int years) returns LocalDateTimeReturns a copy of this date-time with the specified number of years subtracted.
Parameters
- years int - The years to subtract.
Return Type
- LocalDateTime - A new LocalDateTime with the years subtracted.
notify
function notify()Wakes up a single thread that is waiting on this object's monitor. WARNING: Low-level Java synchronization method. Avoid using in business logic.
notifyAll
function notifyAll()Wakes up all threads that are waiting on this object's monitor. WARNING: Low-level Java synchronization method. Avoid using in business logic.
plusInterval
function plusInterval(Period|Duration interval) returns LocalDateTimeReturns a copy of this date-time with the specified period added.
Return Type
- LocalDateTime - A new LocalDateTime with the period added.
plusDays
function plusDays(int days) returns LocalDateTimeReturns a copy of this date-time with the specified number of days added.
Parameters
- days int - The number of days to add.
Return Type
- LocalDateTime - A new LocalDateTime with the days added.
plusHours
function plusHours(int hours) returns LocalDateTimeReturns a copy of this date-time with the specified number of hours added.
Parameters
- hours int - The number of hours to add.
Return Type
- LocalDateTime - A new LocalDateTime with the hours added.
plusMinutes
function plusMinutes(int minutes) returns LocalDateTimeReturns a copy of this date-time with the specified number of minutes added.
Parameters
- minutes int - The number of minutes to add.
Return Type
- LocalDateTime - A new LocalDateTime with the minutes added.
plusMonths
function plusMonths(int months) returns LocalDateTimeReturns a copy of this date-time with the specified number of months added.
Parameters
- months int - The number of months to add.
Return Type
- LocalDateTime - A new LocalDateTime with the months added.
plusNanos
function plusNanos(int nanos) returns LocalDateTimeReturns a copy of this date-time with the specified number of nanoseconds added.
Parameters
- nanos int - The number of nanoseconds to add.
Return Type
- LocalDateTime - A new LocalDateTime with the nanoseconds added.
plusSeconds
function plusSeconds(int seconds) returns LocalDateTimeReturns a copy of this date-time with the specified number of seconds added.
Parameters
- seconds int - The number of seconds to add.
Return Type
- LocalDateTime - A new LocalDateTime with the seconds added.
plusWeeks
function plusWeeks(int weeks) returns LocalDateTimeReturns a copy of this date-time with the specified number of weeks added.
Parameters
- weeks int - The number of weeks to add.
Return Type
- LocalDateTime - A new LocalDateTime with the weeks added.
plusYears
function plusYears(int years) returns LocalDateTimeReturns a copy of this date-time with the specified number of years added.
Parameters
- years int - The number of years to add.
Return Type
- LocalDateTime - A new LocalDateTime with the years added.
toInstant
function toInstant(ZoneOffset offset) returns InstantConverts this date-time to an Instant.
Parameters
- offset ZoneOffset - The zone offset to use.
Return Type
- Instant - An Instant representing the same point on the time-line.
toLocalDate
function toLocalDate() returns LocalDateGets the LocalDate part of this date-time.
Return Type
- LocalDate - The date part of this date-time.
toLocalTime
function toLocalTime() returns LocalTimeGets the LocalTime part of this date-time.
Return Type
- LocalTime - The time part of this date-time.
doWait
function doWait() returns InterruptedException?Causes the current thread to wait until notified. WARNING: Low-level Java synchronization method. Use with caution.
Return Type
- InterruptedException? - An InterruptedException if the thread is interrupted while waiting.
waitWithTimeout
function waitWithTimeout(int timeoutMillis) returns InterruptedException?Causes the current thread to wait until notified or the specified time elapses. WARNING: Low-level Java synchronization method. Use with caution.
Parameters
- timeoutMillis int - The maximum time to wait in milliseconds.
Return Type
- InterruptedException? - An InterruptedException if the thread is interrupted while waiting.
waitWithTimeoutAndNanos
function waitWithTimeoutAndNanos(int timeoutMillis, int nanos) returns InterruptedException?Causes the current thread to wait until notified, with the specified timeout. WARNING: Low-level Java synchronization method. Use with caution.
Parameters
- timeoutMillis int - The maximum time to wait in milliseconds.
- nanos int - Additional nanoseconds to wait.
Return Type
- InterruptedException? - An InterruptedException if the thread is interrupted while waiting.
withDayOfMonth
function withDayOfMonth(int dayOfMonth) returns LocalDateTime|errorReturns a copy of this date-time with the day-of-month altered.
Parameters
- dayOfMonth int - The day-of-month to set (1-31).
Return Type
- LocalDateTime|error - A new LocalDateTime with the day-of-month set.
withDayOfYear
function withDayOfYear(int dayOfYear) returns LocalDateTime|errorReturns a copy of this date-time with the day-of-year altered.
Parameters
- dayOfYear int - The day-of-year to set (1-365/366).
Return Type
- LocalDateTime|error - A new LocalDateTime with the day-of-year set.
withHour
function withHour(int hour) returns LocalDateTime|errorReturns a copy of this date-time with the hour-of-day altered.
Parameters
- hour int - The hour-of-day to set (0-23).
Return Type
- LocalDateTime|error - A new LocalDateTime with the hour set.
withMinute
function withMinute(int minute) returns LocalDateTime|errorReturns a copy of this date-time with the minute-of-hour altered.
Parameters
- minute int - The minute-of-hour to set (0-59).
Return Type
- LocalDateTime|error - A new LocalDateTime with the minute set.
withMonth
function withMonth(int month) returns LocalDateTime|errorReturns a copy of this date-time with the month-of-year altered.
Parameters
- month int - The month-of-year to set (1-12).
Return Type
- LocalDateTime|error - A new LocalDateTime with the month set.
withNano
function withNano(int nano) returns LocalDateTime|errorReturns a copy of this date-time with the nano-of-second altered.
Parameters
- nano int - The nano-of-second to set (0-999,999,999).
Return Type
- LocalDateTime|error - A new LocalDateTime with the nano-of-second set.
withSecond
function withSecond(int second) returns LocalDateTime|errorReturns a copy of this date-time with the second-of-minute altered.
Parameters
- second int - The second-of-minute to set (0-59).
Return Type
- LocalDateTime|error - A new LocalDateTime with the second-of-minute set.
withYear
function withYear(int year) returns LocalDateTime|errorReturns a copy of this date-time with the year altered.
Parameters
- year int - The year to set.
Return Type
- LocalDateTime|error - A new LocalDateTime with the year set.
Fields
- Fields Included from *JObject
- jObj handle
- Fields Included from *Object
- jObj handle
- jObj handle - The handle field that stores the reference to the Java object.
java_time_utils: Locale
Ballerina class mapping for the Java java.util.Locale class.
Constructor
The init function of the Ballerina class mapping the java.util.Locale Java class.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.util.Locale Java class.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.util.Localeobject.
java_time_utils: LocalTime
A time without a time-zone in the ISO-8601 calendar system, such as 10:15:30. This is a value-based class; use of identity-sensitive operations on instances of LocalTime may have unpredictable results and should be avoided.
Constructor
Initializes the class with a handle to a Java object.
init (handle obj)- obj handle - The handle reference to the Java object.
toString
function toString() returns stringReturns the ISO-8601 string representation of this time.
Return Type
- string - The time as a string, e.g., 10:15:30.
atDate
function atDate(LocalDate date) returns LocalDateTimeCombines this time with a date to create a LocalDateTime.
Parameters
- date LocalDate - The date to combine with.
Return Type
- LocalDateTime - The local date-time formed from this time and the specified date.
compareTo
Compares this time to another time.
Parameters
- other LocalTime - The other time to compare to.
Return Type
- int - A negative integer, zero, or a positive integer as this time is less than, equal to, or greater than the specified time.
isEquals
Checks if this time is equal to another object.
Parameters
- other Object - The object to check for equality.
Return Type
- boolean - True if this time is equal to the specified object.
format
function format(DateTimeFormatter formatter) returns stringFormats this time using the specified formatter.
Parameters
- formatter DateTimeFormatter - The formatter to use.
Return Type
- string - The formatted time string.
getClass
function getClass() returns ClassReturns the runtime class of this object.
Return Type
- Class - The Class object representing the runtime class.
getHour
function getHour() returns intGets the hour-of-day field.
Return Type
- int - The hour-of-day, from 0 to 23.
getMinute
function getMinute() returns intGets the minute-of-hour field.
Return Type
- int - The minute-of-hour, from 0 to 59.
getNano
function getNano() returns intGets the nano-of-second field.
Return Type
- int - The nano-of-second, from 0 to 999,999,999.
getSecond
function getSecond() returns intGets the second-of-minute field.
Return Type
- int - The second-of-minute, from 0 to 59.
hashCode
function hashCode() returns intReturns the hash code for this time.
Return Type
- int - A suitable hash code.
isAfter
Checks if this time is after the specified time.
Parameters
- other LocalTime - The other time to compare to.
Return Type
- boolean - True if this time is after the specified time.
isBefore
Checks if this time is before the specified time.
Parameters
- other LocalTime - The other time to compare to.
Return Type
- boolean - True if this time is before the specified time.
minusDuration
Returns a copy of this time with the specified period subtracted.
Parameters
- amount Duration - The amount to subtract.
Return Type
- LocalTime - A LocalTime based on this one with the specified amount subtracted.
minusHours
Returns a copy of this time with the specified number of hours subtracted.
Parameters
- hours int - The hours to subtract.
Return Type
- LocalTime - A LocalTime based on this one with the hours subtracted.
minusMinutes
Returns a copy of this time with the specified number of minutes subtracted.
Parameters
- minutes int - The minutes to subtract.
Return Type
- LocalTime - A LocalTime based on this one with the minutes subtracted.
minusNanos
Returns a copy of this time with the specified number of nanoseconds subtracted.
Parameters
- nanos int - The nanoseconds to subtract.
Return Type
- LocalTime - A LocalTime based on this one with the nanoseconds subtracted.
minusSeconds
Returns a copy of this time with the specified number of seconds subtracted.
Parameters
- seconds int - The seconds to subtract.
Return Type
- LocalTime - A LocalTime based on this one with the seconds subtracted.
notify
function notify()Wakes up a single thread that is waiting on this object's monitor.
notifyAll
function notifyAll()Wakes up all threads that are waiting on this object's monitor.
plusDuration
Returns a copy of this time with the specified period added.
Parameters
- amount Duration - The amount to add.
Return Type
- LocalTime - A LocalTime based on this one with the specified period added.
plusHours
Returns a copy of this time with the specified number of hours added.
Parameters
- hours int - The hours to add.
Return Type
- LocalTime - A LocalTime based on this one with the hours added.
plusMinutes
Returns a copy of this time with the specified number of minutes added.
Parameters
- minutes int - The minutes to add.
Return Type
- LocalTime - A LocalTime based on this one with the minutes added.
plusNanos
Returns a copy of this time with the specified number of nanoseconds added.
Parameters
- nanos int - The nanoseconds to add.
Return Type
- LocalTime - A LocalTime based on this one with the nanoseconds added.
plusSeconds
Returns a copy of this time with the specified number of seconds added.
Parameters
- seconds int - The seconds to add.
Return Type
- LocalTime - A LocalTime based on this one with the seconds added.
toNanoOfDay
function toNanoOfDay() returns intExtracts the time as nanoseconds of day.
Return Type
- int - The nanoseconds of day.
toSecondOfDay
function toSecondOfDay() returns intExtracts the time as seconds of day.
Return Type
- int - The seconds of day.
doWait
function doWait() returns InterruptedException?Waits to be notified by another thread.
Return Type
- InterruptedException? - An error if the wait is interrupted, or () if successful.
waitWithTimeout
function waitWithTimeout(int timeoutMillis) returns InterruptedException?Waits to be notified by another thread for a specified amount of time.
Parameters
- timeoutMillis int - The maximum time to wait in milliseconds.
Return Type
- InterruptedException? - An error if the wait is interrupted, or () if successful.
waitWithTimeoutAndNanos
function waitWithTimeoutAndNanos(int timeoutMillis, int nanos) returns InterruptedException?Waits to be notified by another thread for a specified amount of time.
Parameters
- timeoutMillis int - The maximum time to wait in milliseconds.
- nanos int - The additional nanoseconds to wait.
Return Type
- InterruptedException? - An error if the wait is interrupted, or () if successful.
withHour
Returns a copy of this time with the hour-of-day altered.
Parameters
- hour int - The hour-of-day to set in the result.
withMinute
Returns a copy of this time with the minute-of-hour altered.
Parameters
- minute int - The minute-of-hour to set in the result.
withNano
Returns a copy of this time with the nano-of-second altered.
Parameters
- nano int - The nano-of-second to set in the result.
withSecond
Returns a copy of this time with the second-of-minute altered.
Parameters
- second int - The second-of-minute to set in the result.
Fields
- Fields Included from *JObject
- jObj handle
- Fields Included from *Object
- jObj handle
- jObj handle - The handle to the underlying Java object.
java_time_utils: Map
Ballerina class mapping for the Java java.util.Map interface.
Constructor
The init function of the Ballerina class mapping the java.util.Map Java interface.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.util.Map Java interface.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.util.Mapobject.
java_time_utils: Month
Ballerina class mapping for the Java java.time.Month class.
Represents a month in the year, such as 'July'.
Constructor
The init function of the Ballerina class mapping the java.time.Month Java class.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
describeConstable
function describeConstable() returns OptionalReturns an optional descriptor of this enum constant for use with
nominal descriptors (Java's Constable mechanism).
Method included from *Enum
toString
function toString() returns stringReturns the string representation of the Java Month object instance.
Return Type
- string - The string form of the Java object instance.
compareTo
Compares this month to another enum value.
Parameters
- other Enum - The other enum value to compare against.
Return Type
- int - The negative integer, zero, or positive integer as this object is less than, equal to, or greater than the specified object.
isEquals
Checks if this month is equal to another object.
Parameters
- other Object - The object to check equality with.
Return Type
- boolean - True if the objects are equal, false otherwise.
firstDayOfYear
Gets the day-of-year corresponding to the first day of this month.
Parameters
- leapYear boolean - True if the year is a leap year, false otherwise.
Return Type
- int - The day-of-year for the first day of this month (1 to 335).
firstMonthOfQuarter
function firstMonthOfQuarter() returns MonthGets the first month of the quarter.
Return Type
- Month - The first month of the corresponding quarter.
getClass
function getClass() returns ClassReturns the Class object that represents this month's runtime class.
Return Type
- Class - The Class object.
getDeclaringClass
function getDeclaringClass() returns ClassReturns the declaring class of this enum's type.
Return Type
- Class - The Class object representing the enum type.
getValue
function getValue() returns intReturns the numeric value of the month.
Return Type
- int - The integer value representing the month (1 for January, 12 for December).
hashCode
function hashCode() returns intReturns a hash code for this month.
Return Type
- int - A suitable hash code.
length
Gets the length of the month in days, taking leap years into account.
Parameters
- leapYear boolean - True if the year is a leap year, false otherwise.
Return Type
- int - The length of this month in days.
maxLength
function maxLength() returns intGets the maximum length of this month in days.
Return Type
- int - The maximum length of this month in days (29 to 31).
minLength
function minLength() returns intGets the minimum length of this month in days.
Return Type
- int - The minimum length of this month in days (28 to 31).
minusMonths
Returns the month-of-year that is the specified number of months before this one.
Parameters
- months int - The months to subtract, positive or negative.
Return Type
- Month - The resulting month.
name
function name() returns stringReturns the name of this enum constant, exactly as declared in its enum declaration.
Return Type
- string - The name of this month.
notify
function notify()Wakes up a single thread that is waiting on this object's monitor.
notifyAll
function notifyAll()Wakes up all threads that are waiting on this object's monitor.
ordinal
function ordinal() returns intReturns the ordinal of this enumeration constant (its position in its enum declaration, where the initial constant is assigned an ordinal of zero).
Return Type
- int - The ordinal of this month.
plusMonths
Returns the month-of-year that is the specified number of months after this one.
Parameters
- months int - The months to add, positive or negative.
Return Type
- Month - The resulting month.
doWait
function doWait() returns InterruptedException?Causes the current thread to wait until another thread wakes it up.
Return Type
- InterruptedException? - An InterruptedException if the current thread was interrupted while waiting, or nil otherwise.
waitWithTimeout
function waitWithTimeout(int timeoutMillis) returns InterruptedException?Causes the current thread to wait until another thread wakes it up, or until a specified timeout elapses.
Parameters
- timeoutMillis int - The maximum time to wait in milliseconds.
Return Type
- InterruptedException? - An InterruptedException if the current thread was interrupted while waiting, or nil otherwise.
waitWithTimeoutAndNanos
function waitWithTimeoutAndNanos(int timeoutMillis, int nanos) returns InterruptedException?Causes the current thread to wait until another thread wakes it up, or until a specified timeout and nanoseconds elapse.
Parameters
- timeoutMillis int - The maximum time to wait in milliseconds.
- nanos int - Additional nanoseconds to wait.
Return Type
- InterruptedException? - An InterruptedException if the current thread was interrupted while waiting, or nil otherwise.
Fields
- Fields Included from *JObject
- jObj handle
- Fields Included from *Enum
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.Monthobject.
java_time_utils: Object
Ballerina wrapper for the Java java.lang.Object class.
Object is the root type used across this library so that its many time-related classes
can share a common contract for equality, hashing, and low-level Java thread synchronization.
Constructor
Initializes the Object wrapper.
init (handle obj)- obj handle - The handle value containing the Java reference.
toString
function toString() returns stringReturns the string representation of this object.
Return Type
- string - The string form of the Java object instance.
isEquals
Checks if this object is equal to another object.
Note: this delegates directly to Java's equals method on Object, which
compares by reference identity unless the underlying Java class
overrides it. Subclasses in this library (e.g. LocalDate,
LocalDateTime, LocalTime) provide their own value-based equality
instead of relying on this default behavior.
Parameters
- other Object - The object to compare against.
Return Type
- boolean - True if the two objects are equal, false otherwise.
getClass
function getClass() returns ClassReturns the runtime class of this object.
Return Type
- Class - The Class instance representing this object's runtime type.
hashCode
function hashCode() returns intReturns the hash code value for this object.
Return Type
- int - The hash code.
notify
function notify()Wakes up a single thread that is waiting on this object's monitor.
WARNING: This is a low-level Java synchronization method. Avoid using it in business logic.
notifyAll
function notifyAll()Wakes up all threads that are waiting on this object's monitor.
WARNING: This is a low-level Java synchronization method. Avoid using it in business logic.
doWait
function doWait() returns InterruptedException?Causes the current thread to wait until notified.
WARNING: Low-level Java synchronization method. Use with caution.
Return Type
- InterruptedException? - An InterruptedException if the thread is interrupted while waiting.
waitWithTimeout
function waitWithTimeout(int timeoutMillis) returns InterruptedException?Causes the current thread to wait until notified or the specified time elapses.
WARNING: Low-level Java synchronization method. Use with caution.
Parameters
- timeoutMillis int - The maximum time to wait, in milliseconds.
Return Type
- InterruptedException? - An InterruptedException if the thread is interrupted while waiting.
waitWithTimeoutAndNanos
function waitWithTimeoutAndNanos(int timeoutMillis, int nanos) returns InterruptedException?Causes the current thread to wait until notified, with the specified timeout.
WARNING: Low-level Java synchronization method. Use with caution.
Parameters
- timeoutMillis int - The maximum time to wait, in milliseconds.
- nanos int - Additional nanoseconds to wait (0–999,999).
Return Type
- InterruptedException? - An InterruptedException if the thread is interrupted while waiting.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The handle to the underlying Java object.
java_time_utils: OffsetDateTime
Ballerina class mapping for the Java java.time.OffsetDateTime class.
Constructor
The init function of the Ballerina class mapping the java.time.OffsetDateTime Java class.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.OffsetDateTime Java class.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.OffsetDateTimeobject.
java_time_utils: OffsetTime
Ballerina class mapping for the Java java.time.OffsetTime class.
Constructor
The init function of the Ballerina class mapping the java.time.OffsetTime Java class.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.OffsetTime Java class.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.OffsetTimeobject.
java_time_utils: Optional
Ballerina class mapping for the Java java.util.Optional class.
Constructor
The init function of the Ballerina class mapping the java.util.Optional Java class.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.util.Optional Java class.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.util.Optionalobject.
java_time_utils: ParsePosition
Ballerina class mapping for the Java java.text.ParsePosition class.
Constructor
The init function of the Ballerina class mapping the java.text.ParsePosition Java class.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.text.ParsePosition Java class.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.text.ParsePositionobject.
java_time_utils: Period
Ballerina class mapping for the Java java.time.Period class, representing a date-based amount of time.
Constructor
Initializes a Ballerina Period wrapper around an existing Java Period handle.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringReturns the string representation of the Java Period instance.
Return Type
- string - The string form of the period (e.g., "P1Y2M3D").
isEquals
Checks whether this period is equal to another object.
Parameters
- other Object - The object to compare with this period.
Return Type
- boolean - True if the objects are equal, false otherwise.
getClass
function getClass() returns ClassReturns the runtime class of this object.
Return Type
- Class - The
Classobject representing the runtime class.
getDays
function getDays() returns intGets the amount of days in this period.
Return Type
- int - The amount of days component.
getMonths
function getMonths() returns intGets the amount of months in this period.
Return Type
- int - The amount of months component.
getUnits
function getUnits() returns ListGets the list of units supported by this period.
Return Type
- List - A
Listcontaining the supported temporal units.
getYears
function getYears() returns intGets the amount of years in this period.
Return Type
- int - The amount of years component.
hashCode
function hashCode() returns intReturns a hash code for this period.
Return Type
- int - The hash code value.
isNegative
function isNegative() returns booleanChecks if this period is negative.
Return Type
- boolean - True if any of the three amounts are less than zero.
isZero
function isZero() returns booleanChecks if this period is zero-length.
Return Type
- boolean - True if all three amounts are zero.
minusDays
Returns a copy of this period with the specified number of days subtracted.
Parameters
- days int - The amount of days to subtract, may be negative.
Return Type
- Period - A
Periodbased on this period with the specified days subtracted.
minusMonths
Returns a copy of this period with the specified number of months subtracted.
Parameters
- months int - The amount of months to subtract, may be negative.
Return Type
- Period - A
Periodbased on this period with the specified months subtracted.
minusYears
Returns a copy of this period with the specified number of years subtracted.
Parameters
- years int - The amount of years to subtract, may be negative.
Return Type
- Period - A
Periodbased on this period with the specified years subtracted.
multipliedBy
Returns a copy of this period multiplied by the specified scalar value.
Parameters
- scalar int - The value to multiply by, may be negative.
Return Type
- Period - A
Periodbased on this period multiplied by the scalar.
negated
function negated() returns PeriodReturns a copy of this period with the length negated.
Return Type
- Period - A
Periodbased on this period with the amounts negated.
normalized
function normalized() returns PeriodReturns a copy of this period with the years and months normalized.
Return Type
- Period - A
Periodbased on this period with the amounts normalized.
notify
function notify()Wakes up a single thread that is waiting on this object's monitor.
notifyAll
function notifyAll()Wakes up all threads that are waiting on this object's monitor.
plusDays
Returns a copy of this period with the specified number of days added.
Parameters
- days int - The amount of days to add, may be negative.
Return Type
- Period - A
Periodbased on this period with the specified days added.
plusMonths
Returns a copy of this period with the specified number of months added.
Parameters
- months int - The amount of months to add, may be negative.
Return Type
- Period - A
Periodbased on this period with the specified months added.
plusYears
Returns a copy of this period with the specified number of years added.
Parameters
- years int - The amount of years to add, may be negative.
Return Type
- Period - A
Periodbased on this period with the specified years added.
toTotalMonths
function toTotalMonths() returns intGets the total number of months in this period.
Return Type
- int - The total number of months, calculated as years times 12 plus months.
doWait
function doWait() returns InterruptedException?Causes the current thread to wait until another thread invokes the notify or notifyAll method.
Return Type
- InterruptedException? - An
InterruptedExceptionif the thread was interrupted while waiting, or nil otherwise.
waitWithTimeout
function waitWithTimeout(int timeoutMillis) returns InterruptedException?Causes the current thread to wait until another thread invokes notify or notifyAll, or a specified timeout expires.
Parameters
- timeoutMillis int - The maximum time to wait in milliseconds.
Return Type
- InterruptedException? - An
InterruptedExceptionif the thread was interrupted while waiting, or nil otherwise.
waitWithTimeoutAndNanos
function waitWithTimeoutAndNanos(int timeoutMillis, int nanos) returns InterruptedException?Causes the current thread to wait until another thread invokes notify or notifyAll, or a specified timeout expires with nanosecond precision.
Parameters
- timeoutMillis int - The maximum time to wait in milliseconds.
- nanos int - Additional nanoseconds to wait.
Return Type
- InterruptedException? - An
InterruptedExceptionif the thread was interrupted while waiting, or nil otherwise.
withDays
Returns a copy of this period with the specified amount of days.
Parameters
- days int - The days to represent in the new period.
Return Type
- Period - A
Periodbased on this period with the requested days.
withMonths
Returns a copy of this period with the specified amount of months.
Parameters
- months int - The months to represent in the new period.
Return Type
- Period - A
Periodbased on this period with the requested months.
withYears
Returns a copy of this period with the specified amount of years.
Parameters
- years int - The years to represent in the new period.
Return Type
- Period - A
Periodbased on this period with the requested years.
Fields
- Fields Included from *JObject
- jObj handle
- Fields Included from *Object
- jObj handle
- jObj handle - The underlying Java reference for the
java.time.Periodinstance.
java_time_utils: ResolverStyle
Ballerina class mapping for the Java java.time.format.ResolverStyle class.
Constructor
The init function of the Ballerina class mapping the java.time.format.ResolverStyle Java class.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.format.ResolverStyle Java class.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.format.ResolverStyleobject.
java_time_utils: Set
Ballerina class mapping for the Java java.util.Set interface.
Constructor
The init function of the Ballerina class mapping the java.util.Set Java interface.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.util.Set Java interface.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.util.Setobject.
java_time_utils: Stream
Ballerina class mapping for the Java java.util.stream.Stream interface.
Constructor
The init function of the Ballerina class mapping the java.util.stream.Stream Java interface.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.util.stream.Stream Java interface.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.util.stream.Streamobject.
java_time_utils: Temporal
Ballerina class mapping for the Java java.time.temporal.Temporal interface.
Constructor
The init function of the Ballerina class mapping the java.time.temporal.Temporal Java interface.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.temporal.Temporal Java interface.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.temporal.Temporalobject.
java_time_utils: TemporalAccessor
Ballerina class mapping for the Java java.time.temporal.TemporalAccessor interface.
Constructor
The init function of the Ballerina class mapping the java.time.temporal.TemporalAccessor Java interface.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.temporal.TemporalAccessor Java interface.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.temporal.TemporalAccessorobject.
java_time_utils: TemporalAdjuster
Ballerina class mapping for the Java java.time.temporal.TemporalAdjuster interface.
Constructor
The init function of the Ballerina class mapping the java.time.temporal.TemporalAdjuster Java interface.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.temporal.TemporalAdjuster Java interface.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.temporal.TemporalAdjusterobject.
java_time_utils: TemporalAmount
Ballerina class mapping for the Java java.time.temporal.TemporalAmount interface.
Constructor
The init function of the Ballerina class mapping the java.time.temporal.TemporalAmount Java interface.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.temporal.TemporalAmount Java interface.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.temporal.TemporalAmountobject.
java_time_utils: TemporalField
Ballerina class mapping for the Java java.time.temporal.TemporalField interface.
Constructor
The init function of the Ballerina class mapping the java.time.temporal.TemporalField Java interface.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.temporal.TemporalField Java interface.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.temporal.TemporalFieldobject.
java_time_utils: TemporalQuery
Ballerina class mapping for the Java java.time.temporal.TemporalQuery interface.
Constructor
The init function of the Ballerina class mapping the java.time.temporal.TemporalQuery Java interface.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.temporal.TemporalQuery Java interface.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.temporal.TemporalQueryobject.
java_time_utils: TemporalUnit
Ballerina class mapping for the Java java.time.temporal.TemporalUnit interface.
Constructor
The init function of the Ballerina class mapping the java.time.temporal.TemporalUnit Java interface.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.temporal.TemporalUnit Java interface.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.temporal.TemporalUnitobject.
java_time_utils: TextStyle
Ballerina class mapping for the Java java.time.format.TextStyle class.
Constructor
The init function of the Ballerina class mapping the java.time.format.TextStyle Java class.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.format.TextStyle Java class.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.format.TextStyleobject.
java_time_utils: ValueRange
Ballerina class mapping for the Java java.time.temporal.ValueRange class.
Constructor
The init function of the Ballerina class mapping the java.time.temporal.ValueRange Java class.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.temporal.ValueRange Java class.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.temporal.ValueRangeobject.
java_time_utils: ZonedDateTime
Ballerina class mapping for the Java java.time.ZonedDateTime class.
Constructor
The init function of the Ballerina class mapping the java.time.ZonedDateTime Java class.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.ZonedDateTime Java class.
Return Type
- string - The
stringform of the Java object instance.
isEquals
Checks if this date-time is equal to another date-time.
Parameters
- other Object - The object to check equality with
Return Type
- boolean - True if this is equal to the other object
format
function format(DateTimeFormatter formatter) returns stringFormats this date-time using the specified formatter.
Parameters
- formatter DateTimeFormatter - The formatter to use, not null
Return Type
- string - The formatted date-time string
getClass
function getClass() returns ClassGets the runtime class of this object.
Return Type
- Class - The class object representing the runtime class
getDayOfMonth
function getDayOfMonth() returns intGets the day-of-month field value.
Return Type
- int - The day-of-month, from 1 to 31
getDayOfWeek
function getDayOfWeek() returns DayOfWeekGets the day-of-week field, which is an enum DayOfWeek.
Return Type
- DayOfWeek - The day-of-week, not null
getDayOfYear
function getDayOfYear() returns intGets the day-of-year field value.
Return Type
- int - The day-of-year, from 1 to 365, or 366 in a leap year
getHour
function getHour() returns intGets the hour-of-day field value.
Return Type
- int - The hour-of-day, from 0 to 23
getLong
function getLong(TemporalField temporalField) returns intGets the value of the specified field from this date-time as a long.
Parameters
- temporalField TemporalField - viscoelastic field to get, not null
Return Type
- int - The value for the field
getMinute
function getMinute() returns intGets the minute-of-hour field value.
Return Type
- int - The minute-of-hour, from 0 to 59
getMonth
function getMonth() returns MonthGets the month-of-year field using the Month enum.
Return Type
- Month - The month-of-year, not null
getMonthValue
function getMonthValue() returns intGets the month-of-year field value from 1 to 12.
Return Type
- int - The month-of-year, from 1 to 12
getNano
function getNano() returns intGets the nano-of-second field value.
Return Type
- int - The nano-of-second, from 0 to 999,999,999
getOffset
function getOffset() returns ZoneOffsetGets the zone offset, such as '+02:00'.
Return Type
- ZoneOffset - The zone offset, not null
getSecond
function getSecond() returns intGets the second-of-minute field value.
Return Type
- int - The second-of-minute, from 0 to 59
getYear
function getYear() returns intGets the year field value.
Return Type
- int - The year, from MIN_YEAR to MAX_YEAR
getZone
function getZone() returns ZoneIdGets the time-zone, such as 'Europe/Paris'.
Return Type
- ZoneId - The time-zone, not null
hashCode
function hashCode() returns intGets a hash code for this date-time.
Return Type
- int - A suitable hash code
isAfter
function isAfter(ZonedDateTime other) returns booleanChecks if this date-time is after the specified date-time.
Parameters
- other ZonedDateTime - The other date-time to compare to, not null
Return Type
- boolean - True if this is after the specified date-time
isBefore
function isBefore(ZonedDateTime other) returns booleanChecks if this date-time is before the specified date-time.
Parameters
- other ZonedDateTime - The other date-time to compare to, not null
Return Type
- boolean - True if this is before the specified date-time
isEqual
function isEqual(ZonedDateTime other) returns booleanChecks if this date-time is equal to the specified date-time.
Parameters
- other ZonedDateTime - The other date-time to compare to, not null
Return Type
- boolean - True if the instant timeline moment is equal to the specified date-time
minus
function minus(Duration|Period amount) returns ZonedDateTimeReturns a copy of this date-time with the specified amount subtracted.
Return Type
- ZonedDateTime - A copy of this date-time with the specified amount subtracted, not null
minusDays
function minusDays(int daysToSubtract) returns ZonedDateTimeReturns a copy of this date-time with the specified number of days subtracted.
Parameters
- daysToSubtract int - The days to subtract, may be negative
Return Type
- ZonedDateTime - A copy of this date-time with the specified days subtracted, not null
minusHours
function minusHours(int hoursToSubtract) returns ZonedDateTimeReturns a copy of this date-time with the specified number of hours subtracted.
Parameters
- hoursToSubtract int - The hours to subtract, may be negative
Return Type
- ZonedDateTime - A copy of this date-time with the specified hours subtracted, not null
minusMinutes
function minusMinutes(int minutesToSubtract) returns ZonedDateTimeReturns a copy of this date-time with the specified number of minutes subtracted.
Parameters
- minutesToSubtract int - The minutes to subtract, may be negative
Return Type
- ZonedDateTime - A copy of this date-time with the specified minutes subtracted, not null
minusMonths
function minusMonths(int monthsToSubtract) returns ZonedDateTimeReturns a copy of this date-time with the specified number of months subtracted.
Parameters
- monthsToSubtract int - The months to subtract, may be negative
Return Type
- ZonedDateTime - A copy of this date-time with the specified months subtracted, not null
minusNanos
function minusNanos(int nanosToSubtract) returns ZonedDateTimeReturns a copy of this date-time with the specified number of nanoseconds subtracted.
Parameters
- nanosToSubtract int - The nanos to subtract, may be negative
Return Type
- ZonedDateTime - A copy of this date-time with the specified nanoseconds subtracted, not null
minusSeconds
function minusSeconds(int secondsToSubtract) returns ZonedDateTimeReturns a copy of this date-time with the specified number of seconds subtracted.
Parameters
- secondsToSubtract int - The seconds to subtract, may be negative
Return Type
- ZonedDateTime - A copy of this date-time with the specified seconds subtracted, not null
minusWeeks
function minusWeeks(int weeksToSubtract) returns ZonedDateTimeReturns a copy of this date-time with the specified number of weeks subtracted.
Parameters
- weeksToSubtract int - The weeks to subtract, may be negative
Return Type
- ZonedDateTime - A copy of this date-time with the specified weeks subtracted, not null
minusYears
function minusYears(int yearsToSubtract) returns ZonedDateTimeReturns a copy of this date-time with the specified number of years subtracted.
Parameters
- yearsToSubtract int - The years to subtract, may be negative
Return Type
- ZonedDateTime - A copy of this date-time with the specified years subtracted, not null
notify
function notify()Wakes up a single thread that is waiting on this object's monitor.
notifyAll
function notifyAll()Wakes up all threads that are waiting on this object's monitor.
plus
function plus(Duration|Period amount) returns ZonedDateTimeReturns a copy of this date-time with the specified amount added.
Return Type
- ZonedDateTime - A copy of this date-time with the specified amount added, not null
plusDays
function plusDays(int daysToAdd) returns ZonedDateTimeReturns a copy of this date-time with the specified number of days added.
Parameters
- daysToAdd int - The days to add, may be negative
Return Type
- ZonedDateTime - A copy of this date-time with the specified days added, not null
plusHours
function plusHours(int hoursToAdd) returns ZonedDateTimeReturns a copy of this date-time with the specified number of hours added.
Parameters
- hoursToAdd int - The hours to add, may be negative
Return Type
- ZonedDateTime - A copy of this date-time with the specified hours added, not null
plusMinutes
function plusMinutes(int minutesToAdd) returns ZonedDateTimeReturns a copy of this date-time with the specified number of minutes added.
Parameters
- minutesToAdd int - The minutes to add, may be negative
Return Type
- ZonedDateTime - A copy of this date-time with the specified minutes added, not null
plusMonths
function plusMonths(int monthsToAdd) returns ZonedDateTimeReturns a copy of this date-time with the specified number of months added.
Parameters
- monthsToAdd int - The months to add, may be negative
Return Type
- ZonedDateTime - A copy of this date-time with the specified months added, not null
plusNanos
function plusNanos(int nanosToAdd) returns ZonedDateTimeReturns a copy of this date-time with the specified number of nanoseconds added.
Parameters
- nanosToAdd int - The nanos to add, may be negative
Return Type
- ZonedDateTime - A copy of this date-time with the specified nanoseconds added, not null
plusSeconds
function plusSeconds(int secondsToAdd) returns ZonedDateTimeReturns a copy of this date-time with the specified number of seconds added.
Parameters
- secondsToAdd int - The seconds to add, may be negative
Return Type
- ZonedDateTime - A copy of this date-time with the specified seconds added, not null
plusWeeks
function plusWeeks(int weeksToAdd) returns ZonedDateTimeReturns a copy of this date-time with the specified number of weeks added.
Parameters
- weeksToAdd int - The weeks to add, may be negative
Return Type
- ZonedDateTime - A copy of this date-time with the specified weeks added, not null
plusYears
function plusYears(int yearsToAdd) returns ZonedDateTimeReturns a copy of this date-time with the specified number of years added.
Parameters
- yearsToAdd int - The years to add, may be negative
Return Type
- ZonedDateTime - A copy of this date-time with the specified years added, not null
toEpochSecond
function toEpochSecond() returns intQueries this date-time as the number of seconds from the epoch of 1970-01-01T00:00:00Z.
Return Type
- int - The number of seconds from the epoch of 1970-01-01T00:00:00Z
toInstant
function toInstant() returns InstantConverts this date-time to an Instant.
Return Type
- Instant - An Instant representing the same point on the time-line, not null
toLocalDate
function toLocalDate() returns LocalDateGets the LocalDate part of this date-time.
Return Type
- LocalDate - The date part in ISO-8601 calendar system, not null
toLocalDateTime
function toLocalDateTime() returns LocalDateTimeGets the LocalDateTime part of this date-time.
Return Type
- LocalDateTime - The local date-time part in ISO-8601 calendar system, not null
toLocalTime
function toLocalTime() returns LocalTimeGets the LocalTime part of this date-time.
Return Type
- LocalTime - The time part, not null
toOffsetDateTime
function toOffsetDateTime() returns OffsetDateTimeConverts this date-time to an OffsetDateTime.
Return Type
- OffsetDateTime - An OffsetDateTime formed from the date-time and offset, not null
doWait
function doWait() returns InterruptedException?Causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object.
Return Type
- InterruptedException? - An InterruptedException if the current thread was interrupted while waiting
waitWithTimeout
function waitWithTimeout(int timeoutMillis) returns InterruptedException?Causes the current thread to wait until either another thread invokes the notify() method or the notifyAll() method for this object, or a certain amount of time has elapsed.
Parameters
- timeoutMillis int - The maximum time to wait in milliseconds
Return Type
- InterruptedException? - An InterruptedException if the current thread was interrupted while waiting
waitWithTimeoutAndNanos
function waitWithTimeoutAndNanos(int timeoutMillis, int nanos) returns InterruptedException?Causes the current thread to wait until another thread invokes the notify() method or the notifyAll() method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
Parameters
- timeoutMillis int - The maximum time to wait in milliseconds
- nanos int - Additional time, in nanoseconds, in the range 0-999,999
Return Type
- InterruptedException? - An InterruptedException if the current thread was interrupted while waiting
withDayOfMonth
function withDayOfMonth(int dayOfMonth) returns ZonedDateTime|errorReturns a copy of this date-time with the day-of-month altered.
Parameters
- dayOfMonth int - The day-of-month to set in the result, from 1 to 28-31
Return Type
- ZonedDateTime|error - A copy of this date-time with the specified day-of-month set, not null
withDayOfYear
function withDayOfYear(int dayOfYear) returns ZonedDateTime|errorReturns a copy of this date-time with the day-of-year altered.
Parameters
- dayOfYear int - The day-of-year to set in the result, from 1 to 365-366
Return Type
- ZonedDateTime|error - A copy of this date-time with the specified day-of-year set, not null
withEarlierOffsetAtOverlap
function withEarlierOffsetAtOverlap() returns ZonedDateTimeReturns a copy of this date-time changing the zone offset to the earlier of the two valid offsets at a local time-line gap or overlap.
Return Type
- ZonedDateTime - A copy of this date-time with the earlier offset, not null
withFixedOffsetZone
function withFixedOffsetZone() returns ZonedDateTimeReturns a copy of this date-time with the zone set to the offset.
Return Type
- ZonedDateTime - A copy of this date-time with a fixed zone, not null
withHour
function withHour(int hour) returns ZonedDateTime|errorReturns a copy of this date-time with the hour-of-day altered.
Parameters
- hour int - The hour-of-day to set in the result, from 0 to 23
Return Type
- ZonedDateTime|error - A copy of this date-time with the specified hour set, not null
withLaterOffsetAtOverlap
function withLaterOffsetAtOverlap() returns ZonedDateTimeReturns a copy of this date-time changing the zone offset to the later of the two valid offsets at a local time-line gap or overlap.
Return Type
- ZonedDateTime - A copy of this date-time with the later offset, not null
withMinute
function withMinute(int minute) returns ZonedDateTime|errorReturns a copy of this date-time with the minute-of-hour altered.
Parameters
- minute int - The minute-of-hour to set in the result, from 0 to 59
Return Type
- ZonedDateTime|error - A copy of this date-time with the specified minute set, not null
withMonth
function withMonth(int month) returns ZonedDateTime|errorReturns a copy of this date-time with the month-of-year altered.
Parameters
- month int - The month-of-year to set in the result, from 1 to 12
Return Type
- ZonedDateTime|error - A copy of this date-time with the specified month set, not null
withNano
function withNano(int nanoOfSecond) returns ZonedDateTime|errorReturns a copy of this date-time with the nano-of-second altered.
Parameters
- nanoOfSecond int - The nano-of-second to set in the result, from 0 to 999,999,999
Return Type
- ZonedDateTime|error - A copy of this date-time with the specified nano-of-second set, not null
withSecond
function withSecond(int second) returns ZonedDateTime|errorReturns a copy of this date-time with the second-of-minute altered.
Parameters
- second int - The second-of-minute to set in the result, from 0 to 59
Return Type
- ZonedDateTime|error - A copy of this date-time with the specified second set, not null
withYear
function withYear(int year) returns ZonedDateTime|errorReturns a copy of this date-time with the year altered.
Parameters
- year int - The year to set in the result, from MIN_YEAR to MAX_YEAR
Return Type
- ZonedDateTime|error - A copy of this date-time with the specified year set, not null
withZoneSameInstant
function withZoneSameInstant(ZoneId zone) returns ZonedDateTimeReturns a copy of this date-time with a different time-zone, retaining the instant.
Parameters
- zone ZoneId - The time-zone to change to, not null
Return Type
- ZonedDateTime - A copy of this date-time with the requested zone, retaining the instant, not null
withZoneSameLocal
function withZoneSameLocal(ZoneId zone) returns ZonedDateTimeReturns a copy of this date-time with a different time-zone, retaining the local date-time.
Parameters
- zone ZoneId - The time-zone to change to, not null
Return Type
- ZonedDateTime - A copy of this date-time with the requested zone, retaining the local date-time, not null
Fields
- Fields Included from *JObject
- jObj handle
- Fields Included from *Object
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.ZonedDateTimeobject.
java_time_utils: ZoneId
Ballerina class mapping for the Java java.time.ZoneId class.
Constructor
The init function of the Ballerina class mapping the java.time.ZoneId Java class.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringReturns a string representation of this time-zone ID.
Return Type
- string - The ID of the time-zone as a string, not null
isEquals
Checks if this time-zone is equal to another object.
Parameters
- other Object - The object to compare with this zone ID, can be null
Return Type
- boolean - True if this zone is equal to the specified object, false otherwise
getClass
function getClass() returns ClassReturns the unique runtime class of this zone ID instance.
Return Type
- Class - The Class object representing the runtime class, not null
getId
function getId() returns stringGets the unique time-zone ID.
Return Type
- string - The time-zone ID, not null
hashCode
function hashCode() returns intComputes a hash code for this time-zone ID.
Return Type
- int - A suitable hash code
normalized
function normalized() returns ZoneIdNormalizes the time-zone ID, returning a ZoneOffset where possible.
Return Type
- ZoneId - The normalized zone ID, not null
notify
function notify()Wakes up a single thread that is waiting on this object's monitor.
notifyAll
function notifyAll()Wakes up all threads that are waiting on this object's monitor.
doWait
function doWait() returns InterruptedException?Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
Return Type
- InterruptedException? - An InterruptedException if the waiting thread was interrupted, or nil if successful
waitWithTimeout
function waitWithTimeout(int timeoutMillis) returns InterruptedException?Causes the current thread to wait until it is awakened, or until a specified amount of time has elapsed.
Parameters
- timeoutMillis int - The maximum time to wait in milliseconds
Return Type
- InterruptedException? - An InterruptedException if the waiting thread was interrupted, or nil if successful
waitWithTimeoutAndNanos
function waitWithTimeoutAndNanos(int timeoutMillis, int nanos) returns InterruptedException?Causes the current thread to wait until it is awakened, or until a specified amount of time and nanoseconds has elapsed.
Parameters
- timeoutMillis int - The maximum time to wait in milliseconds
- nanos int - Additional nanoseconds to wait (0-999999)
Return Type
- InterruptedException? - An InterruptedException if the waiting thread was interrupted, or nil if successful
Fields
- Fields Included from *JObject
- jObj handle
- Fields Included from *Object
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.ZoneIdobject.
java_time_utils: ZoneOffset
Ballerina class mapping for the Java java.time.ZoneOffset class.
Constructor
The init function of the Ballerina class mapping the java.time.ZoneOffset Java class.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
getDisplayName
Gets the textual representation of the zone, such as 'British Time' or '+02:00', for the specified display style and locale.
Method included from *ZoneId
getRules
function getRules() returns ZoneRulesGets the rules of the time-zone, which define how the offset changes.
Method included from *ZoneId
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.ZoneOffset Java class.
Return Type
- string - The
stringform of the Java object instance.
compareTo
function compareTo(ZoneOffset other) returns intCompares this offset to another offset in descending order (larger offsets sort first).
Parameters
- other ZoneOffset - The other offset to compare to, not null
Return Type
- int - A negative number if this offset is greater, positive if smaller, zero if equal
isEquals
Checks whether this offset is equal to another object.
Parameters
- other Object - The object to compare with, may be
()
Return Type
- boolean -
trueif this offset is equal to the specified object
getClass
function getClass() returns ClassGets the runtime class of this ZoneOffset object.
Return Type
- Class - The
Classobject representing the runtime class, not null
getId
function getId() returns stringGets the normalized zone offset ID, such as "+02:00" or "Z" for UTC.
Return Type
- string - The zone offset ID
getLong
function getLong(TemporalField fieldToGet) returns intGets the value of the specified field from this offset as a long.
Parameters
- fieldToGet TemporalField - The field to query, not null
Return Type
- int - The value of the field
getTotalSeconds
function getTotalSeconds() returns intGets the total zone offset in seconds, such as +7200 for "+02:00".
Return Type
- int - The total zone offset amount in seconds
hashCode
function hashCode() returns intReturns a hash code value for this offset.
Return Type
- int - A suitable hash code
normalized
function normalized() returns ZoneIdGets the normalized zone ID, replacing zero-offset with ZoneOffset.UTC.
Return Type
- ZoneId - The normalized zone ID, not null
notify
function notify()Wakes up a single thread that is waiting on this object's monitor.
notifyAll
function notifyAll()Wakes up all threads that are waiting on this object's monitor.
query
function query(TemporalQuery temporalQuery) returns ObjectQueries this offset using the specified query.
Parameters
- temporalQuery TemporalQuery - The query to invoke, not null
Return Type
- Object - The query result, may be
()
range
function range(TemporalField fieldToQuery) returns ValueRangeGets the valid range of values for the specified field.
Parameters
- fieldToQuery TemporalField - The field to query the range for, not null
Return Type
- ValueRange - The valid range of values for the field, not null
doWait
function doWait() returns InterruptedException?Causes the current thread to wait until it is woken up on this object's monitor, typically via a call to notify() or notifyAll().
Return Type
- InterruptedException? - An
InterruptedExceptionif the waiting thread is interrupted, otherwise()
waitWithTimeout
function waitWithTimeout(int timeoutMillis) returns InterruptedException?Causes the current thread to wait until either it is woken up or the specified timeout elapses.
Parameters
- timeoutMillis int - The maximum time to wait, in milliseconds
Return Type
- InterruptedException? - An
InterruptedExceptionif the waiting thread is interrupted, otherwise()
waitWithTimeoutAndNanos
function waitWithTimeoutAndNanos(int timeoutMillis, int additionalNanos) returns InterruptedException?Causes the current thread to wait until either it is woken up or the specified timeout elapses, with additional nanosecond precision.
Parameters
- timeoutMillis int - The maximum time to wait, in milliseconds
- additionalNanos int - The additional time to wait, in nanoseconds, from 0 to 999999
Return Type
- InterruptedException? - An
InterruptedExceptionif the waiting thread is interrupted, otherwise()
Fields
- Fields Included from *JObject
- jObj handle
- Fields Included from *ZoneId
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.ZoneOffsetobject.
java_time_utils: ZoneOffsetTransition
Ballerina class mapping for the Java java.time.zone.ZoneOffsetTransition class.
Constructor
The init function of the Ballerina class mapping the java.time.zone.ZoneOffsetTransition Java class.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.zone.ZoneOffsetTransition Java class.
Return Type
- string - The
stringform of the Java object instance.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.zone.ZoneOffsetTransitionobject.
java_time_utils: ZoneRules
Ballerina class mapping for the Java java.time.zone.ZoneRules class.
Constructor
The init function of the Ballerina class mapping the java.time.zone.ZoneRules Java class.
init (handle obj)- obj handle - The
handlevalue containing the Java reference of the object.
toString
function toString() returns stringReturns the string representation of these zone rules.
Return Type
- string - The
stringform of the Java object instance.
isEquals
Checks whether these rules are equal to another object.
Parameters
- other Object - The object to compare with, may be
()
Return Type
- boolean -
trueif these rules are equal to the specified object
getClass
function getClass() returns ClassGets the runtime class of this ZoneRules object.
Return Type
- Class - The
Classobject representing the runtime class, not null
getDaylightSavings
Gets the amount of daylight savings in effect at the specified instant, typically one hour when DST is active and zero when it is not.
Parameters
- instant Instant - The instant to find the daylight savings for, not null
Return Type
- Duration - The amount of daylight savings, not null
getOffset
function getOffset(Instant instant) returns ZoneOffsetGets the offset in effect at the specified instant, accounting for any historical or daylight-saving transitions.
Parameters
- instant Instant - The instant to find the offset for, not null
Return Type
- ZoneOffset - The offset in effect at the given instant, not null
getOffsetForLocalDateTime
function getOffsetForLocalDateTime(LocalDateTime localDateTime) returns ZoneOffsetGets a suitable offset for the specified local date-time. If the local date-time falls in a
gap or overlap, this returns a best-effort single offset rather than the full set of
possibilities — see getValidOffsets for the exhaustive result.
Parameters
- localDateTime LocalDateTime - The local date-time to find the offset for, not null
Return Type
- ZoneOffset - The best available offset for the given local date-time, not null
getStandardOffset
function getStandardOffset(Instant instant) returns ZoneOffsetGets the standard offset in effect at the specified instant, ignoring any daylight-saving adjustment.
Parameters
- instant Instant - The instant to find the standard offset for, not null
Return Type
- ZoneOffset - The standard offset, not null
getTransition
function getTransition(LocalDateTime localDateTime) returns ZoneOffsetTransitionGets the offset transition details for the specified local date-time, if it falls within a gap or overlap caused by a change in offset.
Parameters
- localDateTime LocalDateTime - The local date-time to check, not null
Return Type
- ZoneOffsetTransition - The transition details, or
()if the local date-time is not in a gap or overlap
getTransitionRules
function getTransitionRules() returns ListGets the recurring last transition rules, used to calculate future transitions beyond the last explicitly recorded historical transition.
Return Type
- List - An immutable list of transition rules, not null
getTransitions
function getTransitions() returns ListGets the complete list of historical offset transitions for this zone.
Return Type
- List - An immutable list of transitions, not null
getValidOffsets
function getValidOffsets(LocalDateTime localDateTime) returns ListGets the list of offsets valid for the specified local date-time. Normally returns a single offset; returns two offsets during a local time-line overlap (such as the autumn DST transition), or zero offsets during a gap (such as the spring-forward transition).
Parameters
- localDateTime LocalDateTime - The local date-time to query, not null
Return Type
- List - The list of valid offsets, which may be empty, not null
hashCode
function hashCode() returns intReturns a hash code value for these zone rules.
Return Type
- int - A suitable hash code
isDaylightSavings
Checks whether daylight savings is in effect at the specified instant.
Parameters
- instant Instant - The instant to check, not null
Return Type
- boolean -
trueif daylight savings is in effect at the given instant
isFixedOffset
function isFixedOffset() returns booleanChecks whether this set of rules has a fixed offset that never changes (no daylight
savings, no historical transitions), such as for a plain ZoneOffset.
Return Type
- boolean -
trueif the offset never changes
isValidOffset
function isValidOffset(LocalDateTime localDateTime, ZoneOffset offset) returns booleanChecks whether the specified offset is valid for the specified local date-time.
Parameters
- localDateTime LocalDateTime - The local date-time to check, not null
- offset ZoneOffset - The offset to check, not null
Return Type
- boolean -
trueif the offset is one of the valid offsets for the given local date-time
notify
function notify()Wakes up a single thread that is waiting on this object's monitor.
notifyAll
function notifyAll()Wakes up all threads that are waiting on this object's monitor.
doWait
function doWait() returns InterruptedException?Causes the current thread to wait until it is woken up on this object's monitor, typically via a call to notify() or notifyAll().
Return Type
- InterruptedException? - An
InterruptedExceptionif the waiting thread is interrupted, otherwise()
waitWithTimeout
function waitWithTimeout(int timeoutMillis) returns InterruptedException?Causes the current thread to wait until either it is woken up or the specified timeout elapses.
Parameters
- timeoutMillis int - The maximum time to wait, in milliseconds
Return Type
- InterruptedException? - An
InterruptedExceptionif the waiting thread is interrupted, otherwise()
waitWithTimeoutAndNanos
function waitWithTimeoutAndNanos(int timeoutMillis, int additionalNanos) returns InterruptedException?Causes the current thread to wait until either it is woken up or the specified timeout elapses, with additional nanosecond precision.
Parameters
- timeoutMillis int - The maximum time to wait, in milliseconds
- additionalNanos int - The additional time to wait, in nanoseconds, from 0 to 999999
Return Type
- InterruptedException? - An
InterruptedExceptionif the waiting thread is interrupted, otherwise()
Fields
- Fields Included from *JObject
- jObj handle
- Fields Included from *Object
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.zone.ZoneRulesobject.
Constants
java_time_utils: INTERRUPTEDEXCEPTION
Errors
java_time_utils: InterruptedException
Import
import kruutteri1/java_time_utils;Metadata
Released date: 11 days ago
Version: 1.1.2
License: Apache-2.0
Compatibility
Platform: java21
Ballerina version: 2201.13.4
GraalVM compatible: Yes
Pull count
Total: 9
Current verison: 0
Weekly downloads
Keywords
java-time
date
time
localdate
localdatetime
localtime
zone
Contributors
Dependencies