01: /**
02: * $Id: DateTag.java,v 1.2 2002/06/01 22:16:17 sorensen Exp $
03: * Copyright 2002 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.portal.wireless.taglibs.util;
14:
15: import java.util.Date;
16: import javax.servlet.jsp.*;
17: import javax.servlet.jsp.tagext.*;
18: import com.sun.portal.wireless.taglibs.base.*;
19:
20: /**
21: * DateTag - print current date and time to page.
22: *
23: * @author Robert O'Brien
24: * @version 1.0
25: * @see com.sun.portal.wireless.taglibs.base.BeanTag
26: */
27:
28: public class DateTag extends
29: com.sun.portal.wireless.taglibs.base.BeanTag {
30:
31: /**
32: * Create a new Date bean
33: *
34: * @return Date; set to 'now'
35: */
36: public Object newBean() throws Exception {
37: return new Date();
38: }
39:
40: /**
41: * Print date to page output
42: *
43: * @return EVAL_PAGE
44: * @exception JspException
45: */
46: public int doEndTag() throws JspException {
47: try {
48: pageContext.getOut().println(getBean().toString());
49: } catch (java.io.IOException e) {
50: throw new JspException("DateTag: IO error");
51: }
52: return EVAL_PAGE;
53: }
54: }
|