java_time_utils
Module java_time_utils
API
Declarations
Definitions
kruutteri1/java_time_utils
Overview
A Ballerina wrapper around java.time — LocalDate, LocalDateTime, and LocalTime, and other core helper and enum classes like Month and DayOfWeek for working with dates, times, and temporal components without time zones.
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, immutable values, and predictable behavior, without reaching for a full-blown time-zone library when you don't need one.
Installation
# Ballerina.toml [[dependency]] org = "kruutteri1" name = "java_time_utils" version = "1.0.6" # 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
- ⏳ 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)
- 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
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.
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.
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.
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.
getMidnigth
function getMidnigth() returns LocalTimeRetrieves the value of the public field MIDNIGHT.
Return Type
- LocalTime - The
LocalTimevalue of the field.
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.
getMonthOf
Obtains an instance of Month from an int value.
Parameters
- month int - The month-of-year to represent, from 1 (January) to 12 (December).
getMonthValueOf
Returns the enum constant of this type with the specified name.
Parameters
- name string - The name of the constant to return.
getMonthValueOfEnum
Returns the enum constant of the specified enum type with the specified name.
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 của 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.
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 PeriodRetrieves the constant for a period of zero.
Return Type
- Period - A period of zero.
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.
ofDay
Creates a DayOfWeek from an ISO-8601 numeric value.
Parameters
- dayOfWeek int - The day-of-week value, from 1 (MONDAY) to 7 (SUNDAY).
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.
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.
ofMonth
Obtains a LocalDate from a year, month, and day.
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.
ofNanoOfDay
Obtains an instance of LocalTime from a nanos-of-day value.
Parameters
- nanoOfDay int - The nanos of day.
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.
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.
parse
Parses a string to a LocalDate using the ISO-8601 formatter.
Parameters
- text string - The text to parse, such as "2026-07-15".
parseFormatter
function parseFormatter(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.
parsePeriod
Obtains a Period from a text string such as PnYnMnD.
Parameters
- text string - The text to parse, not null.
parseText
Obtains an instance of LocalTime from a text string, such as "14:28:19".
Parameters
- text string - The text to parse.
parseTextWithFormatter
function parseTextWithFormatter(string text, DateTimeFormatter formatter) returns LocalTime|errorObtains an instance of LocalTime from a text string using a specific formatter.
parseWithFormatter
function parseWithFormatter(string text, DateTimeFormatter formatter) returns LocalDate|errorParses a string to a LocalDate using a specific formatter.
parseWithText
function parseWithText(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.
valueOf
Returns the enum constant of the specified enum type with the specified name.
This is the generic Enum.valueOf(Class, String) form.
valueOfDayName
Returns the DayOfWeek constant with the specified name (e.g. "MONDAY"). Panics if no constant with that name exists.
Parameters
- name string - The name of the constant to return.
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.
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: 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
The function that maps to the equals method of java.time.format.DateTimeFormatter.
Parameters
- arg0 Object - The
Objectvalue required to map with the Java method parameter.
Return Type
- boolean - The
booleanvalue returning from the Java mapping.
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 arg0, int arg1) 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.
- arg1 int - The
intvalue required to map with the Java method parameter.
Return Type
- InterruptedException? - The
InterruptedExceptionvalue returning from the Java mapping.
withDecimalStyle
function withDecimalStyle(DecimalStyle arg0) returns DateTimeFormatterThe function that maps to the withDecimalStyle method of java.time.format.DateTimeFormatter.
Parameters
- arg0 DecimalStyle - The
DecimalStylevalue required to map with the Java method parameter.
Return Type
- DateTimeFormatter - The
DateTimeFormattervalue returning from the Java mapping.
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: 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 stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.Instant 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.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.
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
function isAfter(LocalDate|LocalDateTime other) returns booleanChecks if this date is after the specified date. If a LocalDateTime is given, only its date part (year, month, day) is compared — the time component is ignored.
Parameters
- other LocalDate|LocalDateTime - The other date, or date-time, to compare to (LocalDate, LocalDateTime).
Return Type
- boolean - True if this date is after the specified date.
isBefore
function isBefore(LocalDate|LocalDateTime other) returns booleanChecks if this date is before the specified date. If a LocalDateTime is given, only its date part (year, month, day) is compared — the time component is ignored.
Parameters
- other LocalDate|LocalDateTime - The other date, or date-time, to compare to (LocalDate, LocalDateTime).
Return Type
- boolean - True if this date is before 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.
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.
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.
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).
Return Type
- LocalDate - A new LocalDate with the day-of-month set.
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).
Return Type
- LocalDate - A new LocalDate with the day-of-year set.
withMonth
Returns a copy of this date with the month-of-year altered.
Parameters
- month int - The month-of-year to set (1-12).
Return Type
- LocalDate - A new LocalDate with the month set.
withYear
Returns a copy of this date with the year altered.
Parameters
- year int - The year to set.
Return Type
- LocalDate - A new LocalDate with the year 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.
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|LocalDate other) returns booleanChecks if this date-time is after the specified date-time or date. If a LocalDate is given, only the date part of this date-time is compared — the time component is ignored.
Parameters
- other LocalDateTime|LocalDate - The other date-time, or date, to compare to.
Return Type
- boolean - True if this date-time is after the specified date-time or date.
isBefore
function isBefore(LocalDateTime|LocalDate other) returns booleanChecks if this date-time is before the specified date-time or date. If a LocalDate is given, only the date part of this date-time is compared — the time component is ignored.
Parameters
- other LocalDateTime|LocalDate - The other date-time, or date, to compare to.
Return Type
- boolean - True if this date-time is before the specified date-time or date.
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.
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.
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 LocalDateTimeReturns 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 - A new LocalDateTime with the day-of-month set.
withDayOfYear
function withDayOfYear(int dayOfYear) returns LocalDateTimeReturns 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 - A new LocalDateTime with the day-of-year set.
withHour
function withHour(int hour) returns LocalDateTimeReturns 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 - A new LocalDateTime with the hour set.
withMinute
function withMinute(int minute) returns LocalDateTimeReturns 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 - A new LocalDateTime with the minute set.
withMonth
function withMonth(int month) returns LocalDateTimeReturns 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 - A new LocalDateTime with the month set.
withNano
function withNano(int nano) returns LocalDateTimeReturns 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 - A new LocalDateTime with the nano-of-second set.
withSecond
function withSecond(int second) returns LocalDateTimeReturns 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 - A new LocalDateTime with the second-of-minute set.
withYear
function withYear(int year) returns LocalDateTimeReturns a copy of this date-time with the year altered.
Parameters
- year int - The year to set.
Return Type
- LocalDateTime - 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.
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.
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.
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.
Return Type
- LocalTime - A LocalTime based on this one with the requested hour.
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.
Return Type
- LocalTime - A LocalTime based on this one with the requested minute.
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.
Return Type
- LocalTime - A LocalTime based on this one with the requested nano-of-second.
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.
Return Type
- LocalTime - A LocalTime based on this one with the requested second.
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: 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).
minus
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.
plus
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 different
time-related classes (LocalDate, LocalDateTime, LocalTime) can share
a common contract for equality, hashing, and low-level Java thread
synchronization.@java:Binding {'class: "java.lang.Object"}
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.
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.
Fields
- Fields Included from *JObject
- 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 stringThe function to retrieve the string representation of the Ballerina class mapping the java.time.ZoneId 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.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.
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.
Fields
- Fields Included from *JObject
- jObj handle
- jObj handle - The
handlefield that stores the reference to thejava.time.ZoneOffsetobject.
Constants
java_time_utils: INTERRUPTEDEXCEPTION
Errors
java_time_utils: InterruptedException
Import
import kruutteri1/java_time_utils;Metadata
Released date: 4 days ago
Version: 1.0.6
License: Apache-2.0
Compatibility
Platform: java21
Ballerina version: 2201.13.4
GraalVM compatible: Yes
Pull count
Total: 5
Current verison: 1
Weekly downloads
Keywords
java-time
date
time
localdate
localdatetime
localtime
Contributors
Dependencies