### Question:
ScriptUtils { public static String toScript(Object obj) { StringBuilder sb = new StringBuilder(); if ((obj != null) && (obj instanceof String)) sb.ensureCapacity((int)(((String) obj).length() * 1.66)); try { appendScript(sb, obj, new IdentityHashMap<Object, Boolean>()); } catch (IOException e) { } return sb.toString(); } private  ScriptUtils(); static void writeToStream(final ResponseWriter responseWriter, Object obj); static String toScript(Object obj); static void appendScript(Appendable appendable, Object obj); static void appendEncodedString(Appendable appendable, Object obj); static void appendEncoded(Appendable appendable, Object obj); static String getValidJavascriptName(String script); static String getMD5scriptHash(String script); static boolean shouldRenderAttribute(Object attributeVal); static boolean shouldRenderAttribute(String attributeName, Object attributeVal); static boolean isValidProperty(Object property); static String escapeCSSMetachars(String s);  }### Answer:
@Test public void testTimezoneSerialization() throws Exception { TimeZone utcPlusTwoTZ = TimeZone.getTimeZone("GMT+02:00"); String serializedUTCPlusTwoTZ = dehydrate(ScriptUtils.toScript(utcPlusTwoTZ)); assertThat(serializedUTCPlusTwoTZ, StringContains.containsString("\"DSTSavings\":0")); assertThat(serializedUTCPlusTwoTZ, StringContains.containsString("\"ID\":\"GMT+02:00\"")); assertThat(serializedUTCPlusTwoTZ, StringContains.containsString("\"rawOffset\":7200000")); TimeZone pstTimeZone = TimeZone.getTimeZone("PST"); String serializedPSTTimeZone = dehydrate(ScriptUtils.toScript(pstTimeZone)); assertThat(serializedPSTTimeZone, StringContains.containsString("\"ID\":\"PST\"")); assertThat(serializedPSTTimeZone, StringContains.containsString("\"rawOffset\":-28800000")); TimeZone sfTimeZone = TimeZone.getTimeZone("America/New_York"); String serializedSFTimeZone = dehydrate(ScriptUtils.toScript(sfTimeZone)); assertThat(serializedSFTimeZone, StringContains.containsString("\"ID\":\"America\\/New_York\"")); assertThat(serializedSFTimeZone, StringContains.containsString("\"rawOffset\":-18000000")); }
@Test public void testTimezoneSerialization() throws Exception { TimeZone utcPlusTwoTZ = TimeZone.getTimeZone("GMT+02:00"); String serializedUTCPlusTwoTZ = dehydrate(ScriptUtils.toScript(utcPlusTwoTZ)); assertThat(serializedUTCPlusTwoTZ, CoreMatchers.containsString("\"DSTSavings\":0")); assertThat(serializedUTCPlusTwoTZ, CoreMatchers.containsString("\"ID\":\"GMT+02:00\"")); assertThat(serializedUTCPlusTwoTZ, CoreMatchers.containsString("\"rawOffset\":7200000")); TimeZone pstTimeZone = TimeZone.getTimeZone("PST"); String serializedPSTTimeZone = dehydrate(ScriptUtils.toScript(pstTimeZone)); assertThat(serializedPSTTimeZone, CoreMatchers.containsString("\"ID\":\"PST\"")); assertThat(serializedPSTTimeZone, CoreMatchers.containsString("\"rawOffset\":-28800000")); TimeZone sfTimeZone = TimeZone.getTimeZone("America/New_York"); String serializedSFTimeZone = dehydrate(ScriptUtils.toScript(sfTimeZone)); assertThat(serializedSFTimeZone, CoreMatchers.containsString("\"ID\":\"America\\/New_York\"")); assertThat(serializedSFTimeZone, CoreMatchers.containsString("\"rawOffset\":-18000000")); }