Harnessing the power of Java in Clojure
Code
;; power_of_java_in_clojure.clj
(ns power-of-java-in-clojure
(:import [java.time LocalDate]))
(. LocalDate now)
(. LocalDate (of 2025 7 5))
(. LocalDate (of 2025 7 10))
(def start-date (. LocalDate (of 2025 7 5)))
(def end-date (. LocalDate (of 2025 7 10)))
;; (range start-date end-date) ;; doesn't work
(.plusDays (. LocalDate now) 1)
(defn inc-day [date-time]
(.plusDays date-time 1))
;; (range start-date end-date inc-day) ;; doesn't work
(defn sequence-of-days []
(iterate inc-day (. LocalDate now)))
(take 7 (sequence-of-days))
(defn next-n-days
"Returns a sequence of the next n days.
If n is not supplied, returns a sequence of the next 7 days.
**Examples:**
```clojure
(next-n-days 5)
(next-n-days)
```
"
([n]
(take n (sequence-of-days)))
([]
(next-n-days 7)))
(next-n-days)
(next-n-days 5)