1 28 29 package com.caucho.jstl.rt; 30 31 import com.caucho.jsp.PageContextImpl; 32 import com.caucho.util.L10N; 33 34 import javax.servlet.jsp.JspException ; 35 import javax.servlet.jsp.tagext.TagSupport ; 36 import javax.servlet.jsp.tagext.TryCatchFinally ; 37 import java.util.TimeZone ; 38 39 42 public class FmtTimeZoneTag extends TagSupport implements TryCatchFinally { 43 private static L10N L = new L10N(FmtTimeZoneTag.class); 44 45 private Object _value; 46 47 private Object _oldTimeZone; 48 49 52 public void setValue(Object value) 53 { 54 _value = value; 55 } 56 57 60 public int doStartTag() 61 throws JspException 62 { 63 PageContextImpl pc = (PageContextImpl) pageContext; 64 65 _oldTimeZone = pc.getAttribute("com.caucho.time-zone"); 66 67 Object valueObj = _value; 68 TimeZone timeZone = null; 69 70 if (valueObj instanceof TimeZone ) { 71 timeZone = (TimeZone ) valueObj; 72 } 73 else if (valueObj instanceof String ) { 74 String string = (String ) valueObj; 75 string = string.trim(); 76 77 if (string.equals("")) 78 timeZone = TimeZone.getTimeZone("GMT"); 79 else 80 timeZone = TimeZone.getTimeZone(string); 81 } 82 else 83 timeZone = TimeZone.getTimeZone("GMT"); 84 85 pc.setAttribute("com.caucho.time-zone", timeZone); 86 87 return EVAL_BODY_INCLUDE; 88 } 89 90 93 public void doCatch(Throwable t) 94 throws Throwable 95 { 96 throw t; 97 } 98 99 102 public void doFinally() 103 { 104 if (_oldTimeZone == null) 105 pageContext.removeAttribute("com.caucho.time-zone"); 106 else 107 pageContext.setAttribute("com.caucho.time-zone", _oldTimeZone); 108 } 109 } 110 | Popular Tags |