Jake Slack | 03928ae | 2014-05-13 18:41:56 -0700 | [diff] [blame] | 1 | // |
| 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 | |
| 19 | package org.eclipse.jetty.io; |
| 20 | |
| 21 | import java.text.DateFormatSymbols; |
| 22 | import java.util.Locale; |
| 23 | |
| 24 | import org.eclipse.jetty.util.DateCache; |
| 25 | |
| 26 | public 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 | } |