1 16 17 package org.apache.taglibs.gnat; 18 19 import javax.servlet.jsp.*; 20 import javax.servlet.jsp.tagext.*; 21 import java.util.*; 22 import java.text.SimpleDateFormat ; 23 24 31 32 public class tstampTag extends TagSupport 33 { 34 public tstampTag() 35 { 36 super(); 37 } 38 39 Date d = null; 40 private SimpleDateFormat dstamp = null; 41 private SimpleDateFormat tstamp = null; 42 private SimpleDateFormat today = null; 43 private ResourceBundle gnatRB = ListResourceBundle.getBundle("org.apache.taglibs.gnat.util.GnatTagStrings"); 44 private ResourceBundle gnatERB = ListResourceBundle.getBundle("org.apache.taglibs.gnat.util.GnatExceptionStrings"); 45 46 public int doStartTag() 47 { 48 return SKIP_BODY; 49 } 50 51 public int doEndTag() throws JspTagException 52 { 53 d = new Date(); 54 55 try 56 { 57 dstamp = new SimpleDateFormat ("yyyyMMdd"); 58 pageContext.setAttribute("DSTAMP", dstamp.format(d)); 59 60 tstamp = new SimpleDateFormat ("HHmm"); 61 pageContext.setAttribute("TSTAMP", tstamp.format(d)); 62 63 today = new SimpleDateFormat ("MMMM d yyyy", Locale.US); 64 pageContext.setAttribute("TODAY", today.format(d)); 65 } 66 catch (Exception e) 67 { 68 throw new JspTagException(gnatRB.getString("tstamp.tag") +": "+e.getMessage()); 69 } 70 return EVAL_PAGE; 71 } 72 } 73 | Popular Tags |