Skip to content

Instantly share code, notes, and snippets.

@deluan
Created December 21, 2010 10:55
Show Gist options
  • Save deluan/749785 to your computer and use it in GitHub Desktop.
Save deluan/749785 to your computer and use it in GitHub Desktop.
package com.deluan.grails.util
import java.text.SimpleDateFormat
import com.grailsrocks.cacheheaders.DateFormatterThreadLocal
/**
* This class is used to force CacheHeadersService (from the cache-headers
* plugin) to generate http-dates in english. It MUST be used when the
* locale of your server is not English.
* <p/>
* To use it, put the following configuration in your Config.groovy:
* <pre>
* beans {
* cacheHeadersService {
* dateFormatters = new com.deluan.grails.util.EnglishDateFormatterThreadLocal()
* }
* }
* </pre>
*
* @author Deluan
*/
class EnglishDateFormatterThreadLocal extends DateFormatterThreadLocal {
SimpleDateFormat initialValue() {
def v = new SimpleDateFormat(RFC1123_DATE_FORMAT, Locale.ENGLISH)
v.timeZone = TimeZone.getTimeZone('GMT')
return v
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment