   (:import (com.jolbox.bonecp BoneCPDataSource)
            (org.flywaydb.core Flyway)
            (java.sql Timestamp)
-           (java.io PrintWriter)))
+           (java.io PrintWriter)
+           (java.text SimpleDateFormat)))
 
 (defn start-component [component auto-migration?]
   (if (:datasource component)

     (stop [this#]
       (stop-component this#))))

; provide json serialization
(defn- serialize-sql-timestamp
  "Serializes a sql timestamp to json."
  [^Timestamp timestamp #^PrintWriter out]
  (.print out (json/write-str (str (int (/ (.getTime timestamp) 1000))))))

; add json capability to java.sql.Timestamp
(extend Timestamp json/JSONWriter

(defmacro def-db-component
  "Defines a new database component."
  [name & {:keys [auto-migration?]
           :or   {auto-migration? false}}]
  ; 'configuration' must be provided during initialization
  ; 'datasource' is the internal state
  ; HINT: this component is itself a valid db-spec as its a map with the key 'datasource'
