(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 <[email protected] <javascript:>>
> 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, [email protected] 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 [email protected]
>> <javascript:>
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> [email protected] <javascript:>
>> 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 [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.