@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")); }
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(); }
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(); } }
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(); }
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); }
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);  }