Title here
Summary here
A common requirement in programs is getting the number of seconds, milliseconds, or nanoseconds since the Unix epoch. Here’s how to do it in Clojure.
To run this Clojure program:
In this Clojure version:
java.time.Instant
to work with time, which is similar to Go’s time.Time
.Instant/now
is used to get the current time, equivalent to time.Now()
in Go..getEpochSecond
, .toEpochMilli
, and .getNano
methods to get the time in different units.Instant/ofEpochSecond
is used to create an Instant from seconds or nanoseconds, similar to time.Unix
in Go.Note that Clojure, being a JVM language, uses Java’s time utilities. The concepts are similar, but the syntax and exact method names differ from Go.
Next, we’ll look at another time-related task: time parsing and formatting.