Skip to content

Latest commit

 

History

History
113 lines (73 loc) · 7.75 KB

File metadata and controls

113 lines (73 loc) · 7.75 KB

Java Interop Reference for PTC-Lisp

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

Name Kind Signature Description Notes
Boolean/parseBoolean Static (Boolean/parseBoolean s) Parse "true"/"false" to boolean Compatibility alias for (parse-boolean s). Invalid or non-string input returns nil instead of Java's false/throwing behavior.

java.lang.Double

Name Kind Signature Description Notes
Double/NEGATIVE_INFINITY Constant Double/NEGATIVE_INFINITY, NEGATIVE_INFINITY Negative infinity constant (##-Inf)
Double/NaN Constant Double/NaN, NaN Not-a-Number constant (##NaN)
Double/POSITIVE_INFINITY Constant Double/POSITIVE_INFINITY, POSITIVE_INFINITY Positive infinity constant (##Inf)
Double/parseDouble Static (Double/parseDouble s) Parse string to double Compatibility alias for (parse-double s). Invalid or non-string input returns nil instead of throwing.

java.lang.Float

Name Kind Signature Description Notes
Float/parseFloat Static (Float/parseFloat s) Parse string to float Compatibility alias for (parse-double s); PTC-Lisp uses one floating type. Invalid or non-string input returns nil instead of throwing.

java.lang.Integer

Name Kind Signature Description Notes
Integer/parseInt Static (Integer/parseInt s) Parse string to integer Compatibility alias for (parse-long s). Invalid or non-string input returns nil instead of throwing.

java.lang.Long

Name Kind Signature Description Notes
Long/parseLong Static (Long/parseLong s) Parse string to integer Compatibility alias for (parse-long s). Invalid or non-string input returns nil instead of throwing.

java.lang.String

Name Kind Signature Description Notes
.contains Method (.contains s substr) Returns true if string contains substring
.endsWith Method (.endsWith s suffix) Returns true if string ends with suffix
.indexOf Method (.indexOf s substr), (.indexOf s substr from-index) Index of first occurrence of substring, or -1 if not found Uses grapheme indices (not byte offsets).
.lastIndexOf Method (.lastIndexOf s substr) Index of last occurrence of substring, or -1 if not found Uses grapheme indices (not byte offsets).
.length Method (.length s) Return the grapheme count of a string Returns grapheme count (not byte length), matching count and .indexOf index semantics.
.startsWith Method (.startsWith s prefix) Returns true if string starts with prefix
.substring Method (.substring s start), (.substring s start end) Extract a substring by grapheme index Indices 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.
.toLowerCase Method (.toLowerCase s) Convert string to lower case
.toUpperCase Method (.toUpperCase s) Convert string to upper case

java.lang.System

Name Kind Signature Description Notes
System/currentTimeMillis Static (System/currentTimeMillis), (currentTimeMillis) Return current time in milliseconds since Unix epoch

java.time.Duration

Name Kind Signature Description Notes
.toDays Method (.toDays duration) Return duration length in whole days Partial days truncate toward zero.
.toMillis Method (.toMillis duration) Return duration length in milliseconds Works on Duration values returned by Duration/between.
Duration/between Static (Duration/between start-instant end-instant), (java.time.Duration/between start-instant end-instant) Return a Duration between two DateTime instants Requires DateTime values, such as results from Instant/parse; LocalDate values are intentionally rejected.

java.time.Instant

Name Kind Signature Description Notes
Instant/parse Static (Instant/parse iso-string), (java.time.Instant/parse iso-string), (parse iso-string) Parse an ISO-8601 instant/date-time string to a DateTime Returns 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

Name Kind Signature Description Notes
.minusDays Method (.minusDays local-date n) Subtract days from a LocalDate n must be an integer.
.plusDays Method (.plusDays local-date n) Add days to a LocalDate n must be an integer.
.toEpochDay Method (.toEpochDay local-date) Return LocalDate epoch-day integer Works on LocalDate values returned by LocalDate/parse.
LocalDate/parse Static (LocalDate/parse date-string), (java.time.LocalDate/parse date-string), (parse date-string) Parse an ISO-8601 date string (YYYY-MM-DD) to a Date Returns 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

Name Kind Signature Description Notes
.isAfter Method (.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.
.isBefore Method (.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

Name Kind Signature Description Notes
.getTime Method (.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 value Returns 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).