0

I called

(clj-time.core/last-day-of-the-month 1999 2)

and

(clj-time.core/number-of-days-in-the-month 1999 2)

both throws

java.lang.NoClassDefFoundError org/joda/time/DateTime$Property  org.joda.time.DateTime.dayOfMonth (DateTime.java:1971)

The docs says:

(defn last-day-of-the-month
  ([^long year ^long month]
        (last-day-of-the-month- (date-time year month)))
  ([dt]
        (last-day-of-the-month- dt)))

(defn number-of-days-in-the-month
  (^long [^DateTime dt]
         (day (last-day-of-the-month- dt)))
  (^long [^long year ^long month]
         (day (last-day-of-the-month- (date-time year month)))))

What's the wrong I make?

Thanks!

The following is my project settings and dependencies:


(defproject xxx "0.1.2-SNAPSHOT"
:description ""
:dependencies [[org.clojure/clojure "1.8.0"]

...
             [clj-time "0.11.0"]          

...)

and I tried this in project repl:

clj-time=> clj-time.core/last-day-of-the-month
#object[clj_time.core$last_day_of_the_month 0x6a86b560 "clj_time.core$last_day_of_the_month@6a86b560"]

The above results are getting from the repl server to which I connect through channeling by ssh.

When I run lein repl in the local project folder, I can get the right result:

xxx.core=> (clj-time.core/last-day-of-the-month 2016 2)
#object[org.joda.time.DateTime 0x22a0534e "2016-02-29T00:00:00.000Z"]
xxx.core=> (clj-time.core/number-of-days-in-the-month 2016 2)
29

I am new to Clojure. Is this information useful?


After restarting the repl, the problem is solved now.

cmal
  • 2,062
  • 1
  • 18
  • 35

1 Answers1

1

Works great for me.

project.clj:

(defproject clj "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [
    [org.clojure/clojure "1.9.0-alpha13"]
    [clj-time "0.12.0"]
  ]
  :java-source-paths ["/home/alan/xpr/src"]
  :main ^:skip-aot clj.core
  :target-path "target/%s"
  :profiles {:dev      {:dependencies [[org.clojure/test.check "0.9.0"]] }
             :uberjar  {:aot :all}}
)

main program:

(ns clj.core
  (:require 
    [clj-time.core :as tm] 
  ))

(println :day  (tm/last-day-of-the-month 1999 2))

(println :days (tm/number-of-days-in-the-month 1999 2))

(defn -main [& args])

Result:

~/clj > lein run    
:day #object[org.joda.time.DateTime 0x61884cb1 1999-02-28T00:00:00.000Z]
:days 28
Alan Thompson
  • 29,276
  • 6
  • 41
  • 48
  • Is this relates to the clj-time version? I cannot edit the project settings because I am only a new comer and the project setting is used by many people in our group now. – cmal Oct 28 '16 at 16:33
  • It still works great if I change version to "0.11.0". Perhaps you should create a new project to test, until you get it working. – Alan Thompson Oct 28 '16 at 16:38
  • Thank you for your answer. But my responsibility is to ssh to the remote server and do development there. I do not have the authority to create a new project or even restart the process. I'm new to lisp and repl style development . Is it possible that the repl process may be contaminated by some other's actions before mine so that I may be calling a function that may not be the original one, so I cannot rely on the output of a function to be what I am expecting in a collaborate repl development environment? Thanks. – cmal Oct 29 '16 at 07:20