Groovy's JsonBuilder does not seem to transform timezones in dates to JSON string at all. Or more precisely, it uses GMT always. For example the following code should print the date as midnight of 2001-02-03, GMT +2. But instead, it prints 2001-02-02T22:00:00+0000, i.e. the same date minus 2 hours as if it would be in GMT.
Is there a bug in JsonBuilder or is this a "known feature" that I need to take into account while using the API?
import groovy.json.JsonBuilder
def c = new GregorianCalendar( new Locale( "fi", "FI" ) ) // GMT+2, no DST by default
c.set( 2001, 1, 3, 0, 0 ) // 2001-02-03T00:00:xx, xx is current seconds. Not set as irrelevant
println ( new JsonBuilder( [ date: c.getTime() ] ) ).toString()