deluan
12/21/2010 - 10:55 AM

See http://techbeats.deluan.com/using-cache-headers-plugin-in-a-non-english-s

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
    }
}