KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jzonic > jlo > formatter > tokens > DateToken


1 package org.jzonic.jlo.formatter.tokens;
2
3 import org.jzonic.jlo.LogRecord;
4
5 import java.text.SimpleDateFormat JavaDoc;
6 import java.util.Date JavaDoc;
7
8 /**
9  * User: Mecky
10  * Date: 19.07.2005
11  * Time: 12:17:49
12  */

13 public class DateToken implements FormatterToken {
14
15     private String JavaDoc df = "yyyy/MM/dd HH:mm:ss";
16
17     public String JavaDoc format(LogRecord lr) {
18         SimpleDateFormat JavaDoc formatter = new SimpleDateFormat JavaDoc(df);
19         Date JavaDoc currentTime = new Date JavaDoc();
20         String JavaDoc dateString = formatter.format(currentTime);
21         return dateString;
22     }
23
24     public String JavaDoc getName() {
25         return "date";
26     }
27
28     public void setParameterString(String JavaDoc txt) {
29         df = txt;
30     }
31 }
32
Popular Tags