How to validate date (YYYYMMDD) using clojure

1,141 views
Skip to first unread message

pbi...@gmail.com

unread,
Mar 12, 2018, 6:28:27 PM3/12/18
to Clojure
I am java certified professional.Currently  I am working  Clojure I am still learning clojure.
I am trying to validate date ( YYYYMMDD) using clojure. Any one have idea how can I validate?

Thanks!
Bijay

John Jacobsen

unread,
Mar 12, 2018, 7:53:57 PM3/12/18
to Clojure
Have a look at clj-time: https://github.com/clj-time/clj-time
In particular the clj-time.format namespace.
Cheers!
John

bijay paudel

unread,
Mar 12, 2018, 8:49:05 PM3/12/18
to clo...@googlegroups.com
I need to process Effective Date by reading the data.

At that case how I can do from clojure? Any idea please.

Logical Data Element: Term Effective Date

Required: YYYYMMDD


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Didier

unread,
Mar 12, 2018, 10:02:54 PM3/12/18
to Clojure
Do it as you would in Java, using Clojure/Java interop.

If you paste the Java code for how you'd do it, we can help you convert it to Clojure interop code.

bijay paudel

unread,
Mar 12, 2018, 10:04:43 PM3/12/18
to clo...@googlegroups.com
Any idea how can I use in Clojure spec?

Thanks!
Bijay

--

Didier

unread,
Mar 13, 2018, 12:14:46 AM3/13/18
to Clojure
(defn valid-yyyymmdd?
 
[date]
 
;; Here's the code that you would use in Java, but using Clojure interop, which needs to return true/false if valid.
  ;; So an example:
  (try (let [format (java.time.format.DateTimeFormatter/ofPattern "yyyyMMdd")]
         (java.time.LocalDate/parse date format)
         true)
       (catch java.time.format.DateTimeParseException e
         false)))

(s/def ::yyyymmdd valid-yyyymmdd?)

Now ::yyyymmdd is a spec for strings that formats as yyyyMMdd.


On Monday, 12 March 2018 19:04:43 UTC-7, bijay paudel wrote:
Any idea how can I use in Clojure spec?

Thanks!
Bijay
On Mon, Mar 12, 2018 at 9:02 PM, Didier <did...@gmail.com> wrote:
Do it as you would in Java, using Clojure/Java interop.

If you paste the Java code for how you'd do it, we can help you convert it to Clojure interop code.


On Monday, 12 March 2018 15:28:27 UTC-7, pbi...@gmail.com wrote:
I am java certified professional.Currently  I am working  Clojure I am still learning clojure.
I am trying to validate date ( YYYYMMDD) using clojure. Any one have idea how can I validate?

Thanks!
Bijay

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to

For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.

number 23

unread,
Mar 23, 2018, 9:20:04 AM3/23/18
to clo...@googlegroups.com
try re with clojure.core/re-matches


For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages