KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > modules > dates > DateModule


1 /*
2  * Created on Apr 5, 2005
3  */

4 package com.openedit.modules.dates;
5
6 import java.text.SimpleDateFormat JavaDoc;
7 import java.util.Date JavaDoc;
8
9 import com.openedit.WebPageRequest;
10 import com.openedit.modules.BaseModule;
11 import com.openedit.page.PageAction;
12
13 /**
14  * @author cburkey
15  *
16  */

17 public class DateModule extends BaseModule
18 {
19
20     public void now(WebPageRequest inReq) throws Exception JavaDoc
21     {
22         PageAction inAction = inReq.getCurrentAction();
23         
24         Date JavaDoc date = new Date JavaDoc();
25         inReq.putPageValue("now",date);
26         
27         String JavaDoc format = inReq.getRequestParameter("format");
28         
29         if ( format == null)
30         {
31             format = inAction.getChildValue("format");
32         }
33         if ( format != null)
34         {
35             SimpleDateFormat JavaDoc sformat = new SimpleDateFormat JavaDoc(format);
36             String JavaDoc fdate = sformat.format(date);
37             inReq.putPageValue("formatteddate",fdate);
38         }
39     }
40 }
41
Popular Tags