You've assigned to date-formatter-set-to-gmt-time the return value
from the setTimeZone method call. This method returns null, hence the
null pointer exception when you try to call the format method. 'doto'
might help here, like:
(let [gmt-date-formatter (doto (SimpleDateFormat. "yyyy-MMM-dd HH:mm:ss")
(.setTimeZone
(TimeZone/getTimeZone "GMT")))]
(.format gmt-date-formatter (Date.)))
On 4 March 2013 16:50, larry google groups <[email protected]> wrote:
> I need to get a GMT date. I found this page on StackOverflow:
>
> http://stackoverflow.com/questions/308683/how-can-i-get-the-current-date-and-time-in-utc-or-gmt-in-java
>
> It gives this example:
>
> SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MMM-dd
> HH:mm:ss");
> dateFormatGmt.setTimeZone(TimeZone.getTimeZone("GMT"));
>
> I thought I was following it closely with (this is inside of a (let)
> statement):
>
> date-formatter (new SimpleDateFormat "yyyy-MM-dd'T'HH:mm:ss")
> gmt-timezone (TimeZone/getTimeZone "GMT")
> date-formatter-set-to-gmt-time (.setTimeZone date-formatter gmt-
> timezone)
> created (.format date-formatter-set-to-gmt-time (new Date))
>
> but this line:
>
> created (.format date-formatter-set-to-gmt-time (new Date))
>
> gives me:
>
> java.lang.NullPointerException: null
> Reflector.java:26 clojure.lang.Reflector.invokeInstanceMethod
> omniture.clj:52 mpdv-clojure.omniture/omniture-make-headers-
> for-api-call
>
> Can anyone tell me why?
>
>
>
>
>
>
>
> --
> --
> 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/groups/opt_out.
>
>
--
--
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/groups/opt_out.