ย 

Module java_time_utils

kruutteri1/java_time_utils

1.0.4

Overview

A Ballerina wrapper around java.time โ€” LocalDate, LocalDateTime, and LocalTime for working with dates and times 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

Copy
# Ballerina.toml
[[dependency]]
org = "kruutteri1"
name = "java_time_utils"
version = "1.0.4"  # check central.ballerina.io for the latest version
Copy
import kruutteri1/java_time_utils as jt;

Quick Start

Copy
import ballerina/io;
import kruutteri1/java_time_utils as jt;

public function main() {
    jt:LocalDate date = jt:ofDate(2026, 7, 15);
    jt:LocalTime time = jt:ofTimeWithSecond(14, 28, 19);
    jt:LocalDateTime dateTime = 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

Copy
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());
    io:println("Now: ", now.toString());
    io:println("Current date-time: ", currentDateTime.toString());
}

Features

  • ๐Ÿ“… LocalDate โ€” dates without time or time zone
  • ๐Ÿ—“๏ธ LocalDateTime โ€” dates with time, no time zone
  • ๐Ÿ•’ LocalTime โ€” time of day without date or time zone
  • Immutable API โ€” every plus*, minus*, and with* method returns a new object
  • Familiar java.time semantics, ported to idiomatic Ballerina

Import

import kruutteri1/java_time_utils;Copy

Other versions

Metadata

Released date:ย about 4 hours ago

Version:ย 1.0.4

License:ย Apache-2.0


Compatibility

Platform:ย java21

Ballerina version:ย 2201.13.4

GraalVM compatible:ย Yes


Pull count

Total:ย 2

Current verison:ย 0


Weekly downloads


Source repository


Keywords

java-time

date

time

localdate

localdatetime

localtime


Contributors