I'm running across something very strange. If i println new Date() in a controller the output is in UTC format (which is what I want). But when I print new Date() from a grails gsp the date is in EDT format and is off.
I'm running my app on CentOS Linux 6.5 through Tomcat 7. The system date and hardware date is using UTC.
Here is my Java version:
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
I've tried adding:
TimeZone.setDefault(TimeZone.getTimeZone("UTC"))
To my bootstrap, but it still doesn't use UTC in the view.
Basically I want everything to use UTC but the only time it isn't is when I print new Date() from within a view.
Any thoughts?
EDIT:
I don't believe formatDate will work for me because I'm not actually just displaying the date for the user. I'm comparing the new Date() object to another date. I just printed the date to the response because I wanted to see why comparing the dates wasn't working. Here is the code snippet I'm using with the new Date() object:
<g:set var="dateNow" value="${new Date()}" />
<g:if test="${ticket.ticketEndDate.before(dateNow)}">
<div>
Ticket closed on ${ticket.ticketEndDate.format('EEE MMM dd, yyyy hh:mm a')}.
</div>
</g:if>