1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.tuigwaa.plugin.basic;
17
18 import java.text.DateFormat;
19 import java.text.SimpleDateFormat;
20 import java.util.Date;
21
22 import org.seasar.tuigwaa.cms.core.CmsRequest;
23 import org.seasar.tuigwaa.cms.core.CmsResponse;
24 import org.seasar.tuigwaa.plugin.AbstractPlugin;
25 import org.seasar.tuigwaa.plugin.PluginException;
26 import org.seasar.tuigwaa.plugin.PluginRequest;
27
28
29 public class DatePlugin extends AbstractPlugin {
30
31 private static final DateFormat DATE_FORMAT = new SimpleDateFormat("yyyy/MM/dd");
32 private static final DateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm:ss");
33 private static final DateFormat NOW_FORMAT = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss (EEE)");
34
35 public String doHTMLView(CmsRequest request, CmsResponse response,
36 PluginRequest prequest) throws PluginException {
37
38 String name = prequest.getName();
39 Date date = new Date();
40
41 String ret = null;
42 if(name.equals("time")){
43 ret = TIME_FORMAT.format(date);
44 }else if(name.equals("now")){
45 ret = NOW_FORMAT.format(date);
46 }else{
47 ret = DATE_FORMAT.format(date);
48 }
49 return ret;
50 }
51
52 }