blob: d92d57ff7fb2c2fc5a2f41c1b3281e27200e9e21 [file] [log] [blame]
Jake Slack03928ae2014-05-13 18:41:56 -07001//
2// ========================================================================
3// Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
4// ------------------------------------------------------------------------
5// All rights reserved. This program and the accompanying materials
6// are made available under the terms of the Eclipse Public License v1.0
7// and Apache License v2.0 which accompanies this distribution.
8//
9// The Eclipse Public License is available at
10// http://www.eclipse.org/legal/epl-v10.html
11//
12// The Apache License v2.0 is available at
13// http://www.opensource.org/licenses/apache2.0.php
14//
15// You may elect to redistribute this code under either of these licenses.
16// ========================================================================
17//
18
19package org.eclipse.jetty.io;
20
21import java.text.DateFormatSymbols;
22import java.util.Locale;
23
24import org.eclipse.jetty.util.DateCache;
25
26public class BufferDateCache extends DateCache
27{
28 Buffer _buffer;
29 String _last;
30
31 public BufferDateCache()
32 {
33 super();
34 }
35
36 public BufferDateCache(String format, DateFormatSymbols s)
37 {
38 super(format,s);
39 }
40
41 public BufferDateCache(String format, Locale l)
42 {
43 super(format,l);
44 }
45
46 public BufferDateCache(String format)
47 {
48 super(format);
49 }
50
51 public synchronized Buffer formatBuffer(long date)
52 {
53 String d = super.format(date);
54 if (d==_last)
55 return _buffer;
56 _last=d;
57 _buffer=new ByteArrayBuffer(d);
58
59 return _buffer;
60 }
61}