2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 package org.apache.log4j.helpers;
20 import java.util.Date;
21 import java.text.FieldPosition;
22 import java.text.ParsePosition;
23 import java.text.DateFormat;
26 Formats a {@link Date} by printing the number of milliseconds
27 elapsed since construction of the format. This is the fastest
28 printing DateFormat in the package.
30 @author Ceki Gülcü
34 public class RelativeTimeDateFormat extends DateFormat {
35 private static final long serialVersionUID = 7055751607085611984L;
38 protected final long startTime;
41 RelativeTimeDateFormat() {
42 this.startTime = System.currentTimeMillis();
46 Appends to <code>sbuf</code> the number of milliseconds elapsed
47 since the start of the application.
52 StringBuffer format(Date date, StringBuffer sbuf,
53 FieldPosition fieldPosition) {
54 //System.err.println(":"+ date.getTime() + " - " + startTime);
55 return sbuf.append((date.getTime() - startTime));
59 This method does not do anything but return <code>null</code>.
62 Date parse(java.lang.String s, ParsePosition pos) {