Java Interop Reference for PTC-Lisp

Copy Markdown View Source

Warning: This file is auto-generated by mix ptc.gen_docs from priv/functions.exs. Manual edits will be overwritten. Edit priv/functions.exs instead.

PTC-Lisp emulates a subset of Java interop for LLM compatibility. These are not real JVM calls — they are BEAM-native implementations that mirror the Java API surface LLMs are trained on.

30 interop entries across 12 classes.

See also: Function Reference | PTC-Lisp Specification | Namespace Coverage

java.lang.Boolean

NameKindSignatureDescriptionNotes
Boolean/parseBooleanStatic(Boolean/parseBoolean s)Parse "true"/"false" to booleanMatches java.lang.Boolean.parseBoolean: nil/null and every string other than case-insensitive "true" return false; non-string, non-nil inputs raise.

java.lang.Double

NameKindSignatureDescriptionNotes
Double/NEGATIVE_INFINITYConstantDouble/NEGATIVE_INFINITY, NEGATIVE_INFINITYNegative infinity constant (##-Inf)
Double/NaNConstantDouble/NaN, NaNNot-a-Number constant (##NaN)
Double/POSITIVE_INFINITYConstantDouble/POSITIVE_INFINITY, POSITIVE_INFINITYPositive infinity constant (##Inf)
Double/parseDoubleStatic(Double/parseDouble s)Parse string to doubleCompatibility alias for (parse-double s). Invalid or non-string input returns nil instead of throwing.

java.lang.Float

NameKindSignatureDescriptionNotes
Float/parseFloatStatic(Float/parseFloat s)Parse string to floatCompatibility alias for (parse-double s); PTC-Lisp uses one floating type. Invalid or non-string input returns nil instead of throwing.

java.lang.Integer

NameKindSignatureDescriptionNotes
Integer/parseIntStatic(Integer/parseInt s)Parse string to integerCompatibility alias for (parse-long s). Invalid or non-string input returns nil instead of throwing.

java.lang.Long

NameKindSignatureDescriptionNotes
Long/parseLongStatic(Long/parseLong s)Parse string to integerCompatibility alias for (parse-long s). Invalid or non-string input returns nil instead of throwing.

java.lang.String

NameKindSignatureDescriptionNotes
.containsMethod(.contains s substr)Returns true if string contains substring
.endsWithMethod(.endsWith s suffix)Returns true if string ends with suffix
.indexOfMethod(.indexOf s substr), (.indexOf s substr from-index)Index of first occurrence of substring, or -1 if not foundUses grapheme indices (not byte offsets).
.lastIndexOfMethod(.lastIndexOf s substr)Index of last occurrence of substring, or -1 if not foundUses grapheme indices (not byte offsets).
.lengthMethod(.length s)Return the grapheme count of a stringReturns grapheme count (not byte length), matching count and .indexOf index semantics.
.startsWithMethod(.startsWith s prefix)Returns true if string starts with prefix
.substringMethod(.substring s start), (.substring s start end)Extract a substring by grapheme indexIndices are grapheme-based (not byte offsets). Two-arg form returns graphemes in [start, end). Raises on out-of-range indices (matches Java's StringIndexOutOfBoundsException) — note that (.substring s -1) raises rather than silently returning the last grapheme, which matters when chaining .indexOf.
.toLowerCaseMethod(.toLowerCase s)Convert string to lower case
.toUpperCaseMethod(.toUpperCase s)Convert string to upper case

java.lang.System

NameKindSignatureDescriptionNotes
System/currentTimeMillisStatic(System/currentTimeMillis), (currentTimeMillis)Return current time in milliseconds since Unix epoch

java.time.Duration

NameKindSignatureDescriptionNotes
.toDaysMethod(.toDays duration)Return duration length in whole daysPartial days truncate toward zero.
.toMillisMethod(.toMillis duration)Return duration length in millisecondsWorks on Duration values returned by Duration/between.
Duration/betweenStatic(Duration/between start-instant end-instant), (java.time.Duration/between start-instant end-instant)Return a Duration between two DateTime instantsRequires DateTime values, such as results from Instant/parse; LocalDate values are intentionally rejected.

java.time.Instant

NameKindSignatureDescriptionNotes
Instant/parseStatic(Instant/parse iso-string), (java.time.Instant/parse iso-string), (parse iso-string)Parse an ISO-8601 instant/date-time string to a DateTimeReturns an Elixir DateTime. Accepts an offset (Z, +02:00, …); an offsetless ...T... string is treated as UTC. .isBefore / .isAfter / .getTime work on the result. A bare YYYY-MM-DD string returns a Date instead (see LocalDate/parse). Also available as the bare parse builtin.

java.time.LocalDate

NameKindSignatureDescriptionNotes
.minusDaysMethod(.minusDays local-date n)Subtract days from a LocalDaten must be an integer.
.plusDaysMethod(.plusDays local-date n)Add days to a LocalDaten must be an integer.
.toEpochDayMethod(.toEpochDay local-date)Return LocalDate epoch-day integerWorks on LocalDate values returned by LocalDate/parse.
LocalDate/parseStatic(LocalDate/parse date-string), (java.time.LocalDate/parse date-string), (parse date-string)Parse an ISO-8601 date string (YYYY-MM-DD) to a DateReturns an Elixir Date for YYYY-MM-DD. If the string carries a time component (...T...) it returns a DateTime instead (see Instant/parse) — a divergence from Java's strict LocalDate.parse. Also available as the bare parse builtin.

java.time.LocalDate / java.util.Date

NameKindSignatureDescriptionNotes
.isAfterMethod(.isAfter a b)Returns true if receiver comes strictly after argument (same-type only)Works on both LocalDate and DateTime. Mixed types raise an error.
.isBeforeMethod(.isBefore a b)Returns true if receiver comes strictly before argument (same-type only)Works on both LocalDate and DateTime. Mixed types raise an error.

java.util.Date

NameKindSignatureDescriptionNotes
.getTimeMethod(.getTime date)Return Unix timestamp in milliseconds from DateTime
java.util.Date.Constructor(java.util.Date.), (java.util.Date. timestamp-or-string), (java.util.Date. datetime-or-date)Construct current UTC time, from a timestamp / ISO-8601 / RFC-2822 string, or pass through an existing temporal valueReturns Elixir DateTime. Accepts integer (seconds or ms auto-detected), ISO-8601 (with or without offset — offsetless is treated as UTC), RFC 2822, or an existing DateTime/NaiveDateTime/Date (Date and NaiveDateTime upgrade to UTC; DateTime returns as-is). Time alone is not accepted (no date component).