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.Calendar;
21 import java.util.TimeZone;
22 import java.util.Date;
23 import java.text.FieldPosition;
24 import java.text.ParsePosition;
25 import java.text.DateFormatSymbols;
28 Formats a {@link Date} in the format "dd MMM yyyy HH:mm:ss,SSS" for example,
29 "06 Nov 1994 15:49:37,459".
31 @author Ceki Gülcü
34 public class DateTimeDateFormat extends AbsoluteTimeDateFormat {
35 private static final long serialVersionUID = 5547637772208514971L;
40 DateTimeDateFormat() {
42 shortMonths = new DateFormatSymbols().getShortMonths();
46 DateTimeDateFormat(TimeZone timeZone) {
48 setCalendar(Calendar.getInstance(timeZone));
52 Appends to <code>sbuf</code> the date in the format "dd MMM yyyy
53 HH:mm:ss,SSS" for example, "06 Nov 1994 08:49:37,459".
55 @param sbuf the string buffer to write to
58 StringBuffer format(Date date, StringBuffer sbuf,
59 FieldPosition fieldPosition) {
61 calendar.setTime(date);
63 int day = calendar.get(Calendar.DAY_OF_MONTH);
69 sbuf.append(shortMonths[calendar.get(Calendar.MONTH)]);
72 int year = calendar.get(Calendar.YEAR);
76 return super.format(date, sbuf, fieldPosition);
80 This method does not do anything but return <code>null</code>.
83 Date parse(java.lang.String s, ParsePosition pos) {